[!--quoteo(post=366979:date=Apr 20 2006, 08:44 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 20 2006, 08:44 PM) [snapback]366979[/snapback][/div][div class=\'quotemain\'][!--quotec--] Something like this? [code]$sql = "SELECT s.student_name, m.module_code, m.module_name, l.lecture_id, l.lec_date FROM student s INNER JOIN student_models sm ON s.student_id = sm_student_id INNER JOIN module m ON sm.module_code = m.module_code INNER JOIN lecture l ON l.module_code = m.module_code WHERE s.student_id = '$sid' ORDER BY m.module_name, l.lec_date"; $res = mysql_query($sql) or die (mysql_error()); list ($sname, $modcode, $modname, $lecid, $lecdate) = mysql_fetch_row($res); echo "<h3>$sname</h3>"; $prevmod = ''; do { if ($prevmod != $modcode) { echo "<h4>$modcode - $modname</h4>"; $prevmod = $modcode; } echo "$lecid $lecdate<br>"; } while (list ($sname, $modcode, $modname, $lecid, $lecdate) = mysql_fetch_row($res));[/code] [/quote] thanks that seems 2 work, there arent any errors but im not sure how 2 test it and if i have an input what it should be