What are the advantages of using the "Select count" approach instead of "Select *" in PHP MySQL queries?

Using the "Select count" approach instead of "Select *" in PHP MySQL queries can improve query performance and reduce the amount of data transferred between the database and the application. By only selecting the count of rows that meet the specified criteria, unnecessary data is not fetched, leading to faster query execution times and lower memory usage.

// Using "Select count" approach
$query = "SELECT COUNT(*) FROM table_name WHERE condition = 'value'";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_array($result);
$count = $row[0];
echo "Total rows: " . $count;