What function in PHP can be used to count the number of rows returned from a MySQL query?

To count the number of rows returned from a MySQL query in PHP, you can use the mysqli_num_rows() function. This function takes the result set returned by the query as a parameter and returns the number of rows in that result set. You can use this count to determine how many rows were returned by your query.

// Assuming $conn is the mysqli connection object and $query is your MySQL query
$result = mysqli_query($conn, $query);
$row_count = mysqli_num_rows($result);

echo "Number of rows returned: " . $row_count;