<?php
$hostname = "localhost";
$user = "root";
$password = "";
$dbname = "abcd";
$conn = new mysqli($hostname, $user, $password, $dbname);
$sql="SELECT YEAR(date) as year from events GROUP BY year";
$row2 = mysqli_fetch_array(mysqli_query($conn,$sql));
$result2 = $conn->query($sql);
$eyear=$row2['year'];
$year="2017";
for ($counter = 1; $counter <=5; $counter++){
echo'<p><a href="'.$eyear.'">'.$year.'</a></p>';
$year--;
}
?>
我想检索不同年份的记录,并在一个页面中显示特定年份的结果