How can the mysql_num_rows() function be used to determine if data is present in a query result?

The mysql_num_rows() function can be used to determine if data is present in a query result by returning the number of rows in the result set. If the number of rows returned is greater than 0, then data is present. This function is commonly used in conjunction with a SELECT query to check if any results were returned.

// Execute a SELECT query
$result = mysql_query("SELECT * FROM table_name");

// Check if data is present in the result set
if(mysql_num_rows($result) > 0) {
    echo "Data is present in the query result.";
} else {
    echo "No data found.";
}