I have a MySQL database that looks similar to this:
ID Group Name 1 1 John 2 1 Andrea 3 1 Jack 4 2 Mike
Try this:
// SQL stuff $group = null; while($row = mysql_fetch_array($result)) { if($row['group'] != $group) { echo $row['group']; $group = $row['group']; } $row['name']; }