$showyear = "select * from grade a
left join user_log b on a.studentID=b.studentID
where b.userID=9 group by a.year,a.term";
$rec_year = mysql_query($showyear);
$showyear = "select * from grade a
left join user_log b on a.studentID=b.studentID
where b.userID=9 group by a.year,a.term";
$rec_year = mysql_query($showyear);
-- เพิ่ม $result = mysql_fetch_array($rec_year );
...