What is the function used in PHP to count the number of selected query results from a database?

To count the number of selected query results from a database in PHP, you can use the mysqli_num_rows() function. This function returns the number of rows in a result set. You can use it after executing a SELECT query to get the count of the selected records.

// Assuming $conn is your database connection and $query is your SELECT query
$result = mysqli_query($conn, $query);
$count = mysqli_num_rows($result);

echo "Number of selected results: " . $count;