What are some alternative methods for retrieving Count results in MySQL queries using PHP?

When retrieving Count results in MySQL queries using PHP, one common method is to use the `mysqli_num_rows` function after executing the query. However, an alternative approach is to use the `COUNT(*)` function directly in the SQL query and fetch the result using `mysqli_fetch_array`.

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

// Query to retrieve count using COUNT(*)
$query = "SELECT COUNT(*) as count FROM table_name";
$result = mysqli_query($connection, $query);

// Fetch the count result
$row = mysqli_fetch_array($result);
$count = $row['count'];

// Display the count
echo "Count: " . $count;

// Close the connection
mysqli_close($connection);