<?php
$QUERY = "SELECT year FROM table GROUP BY year ORDER BY id DESC";
$res = mysql_query($QUERY) or die ("$msgSQL");
while($row = mysql_fetch_array($res)){
echo $row['year'];
$SQL = "SELECT * FROM table ORDER BY id DESC";
$rs = mysql_query($SQL) or die ("$msgSQL");
while($rw = mysql_fetch_array($rs)){
echo $rw['product'];
}
}
?>
ขอบคุณมากครับ
-------------
<?php
$QUERY = "SELECT year FROM table GROUP BY year ORDER BY id DESC";
$res = mysql_query($QUERY) or die ("$msgSQL");
while($row = mysql_fetch_array($res)){
echo $row['year'];
$SQL = "SELECT * FROM table WHERE year = '".$row['year']."' ORDER BY id DESC";
$rs = mysql_query($SQL) or die ("$msgSQL");
while($rw = mysql_fetch_array($rs)){
echo $rw['product'];
}
}
?>
-------------