I have a mysql table that includes the fields:
Name - Year - Description
I'd like to display in order by year, but want to split into to columns by decade. My PHP skills are pretty weak, so I only know how to do it the long way where I make a separate query based on the year range:
<?php
echo "<div><h3>1950</h3>";
$list1950 = mysql_query("SELECT * FROM people WHERE class_year1 > '1949' AND class_year1 < '1960' ORDER BY class_year1, last_name",$db);
while ($thearray = mysql_fetch_array($list1950)) {
echo "<div>$thearray[name] - $thearray[class_year1]<br />$thearray[description]</div>";
}
echo "</div>";
echo "<h3>1960</h3><div>";
$list1960 = mysql_query("SELECT * FROM people WHERE class_year1 > '1959' AND class_year1 < '1970' ORDER BY class_year1, last_name",$db);
while ($thearray = mysql_fetch_array($list1960)) {
echo "<div>$thearray[name] - $thearray[class_year1]<br />$thearray[description]</div>";
}
echo "</div>";
?>
I know there's an easy/more efficient way to do this. Any help?
thanks