How can the PHP code be modified to query data in 10-year intervals instead of individual years?

To query data in 10-year intervals instead of individual years, you can modify the SQL query to group the data by a 10-year interval using the SQL `YEAR()` and integer division operator `DIV`. By grouping the data in this way, you can retrieve aggregated results for each 10-year period.

$query = "SELECT YEAR(date_column) DIV 10 * 10 AS decade, SUM(value_column) AS total_value 
          FROM your_table_name 
          GROUP BY decade";
$result = mysqli_query($connection, $query);

if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        echo "Decade: " . $row['decade'] . " Total Value: " . $row['total_value'] . "<br>";
    }
} else {
    echo "No results found.";
}