What function should be used instead of mysql_fetch_row to ensure the correct number of rows are displayed in the table?

Using the mysql_fetch_row function in PHP can sometimes lead to incorrect results, especially when trying to display the total number of rows in a table. To ensure the correct number of rows are displayed, it is recommended to use the mysqli_num_rows function instead. This function returns the number of rows in a result set, which can be used to accurately display the total number of rows in a table.

// Connect to the database
$conn = mysqli_connect("localhost", "username", "password", "database");

// Execute a query
$result = mysqli_query($conn, "SELECT * FROM table");

// Get the total number of rows
$total_rows = mysqli_num_rows($result);

// Display the total number of rows
echo "Total rows: " . $total_rows;