What is the best way to retrieve the highest number for each day in a PHP query?

To retrieve the highest number for each day in a PHP query, you can use the GROUP BY clause along with the MAX() function in your SQL query. This will allow you to group the data by day and retrieve the maximum number for each day.

$sql = "SELECT DATE(date_column) as day, MAX(number_column) as highest_number 
        FROM your_table_name 
        GROUP BY DATE(date_column)";
$result = mysqli_query($connection, $sql);

if(mysqli_num_rows($result) > 0) {
    while($row = mysqli_fetch_assoc($result)) {
        echo "Highest number for " . $row['day'] . ": " . $row['highest_number'] . "<br>";
    }
} else {
    echo "No results found.";
}