How can the mysql_result function be used to retrieve the result of a count(*) query in PHP?

The mysql_result function can be used to retrieve the result of a count(*) query in PHP by passing the query result resource, row number, and field offset as parameters. The row number should be set to 0 as count(*) queries return a single row result. The field offset should be set to 0 as well since count(*) queries return a single field result.

$query = "SELECT COUNT(*) FROM table_name";
$result = mysql_query($query);
$count = mysql_result($result, 0, 0);
echo "Total count: " . $count;