using implode function
Posted: Sun Jul 13, 2008 1:13 pm
Hello,
I have 2 tables
tbl1:- id, stud_name, class_id
tbl2:-class_id, class_name
I have to display results in the below format,
class_name
student1, student2,....
The code i wrote is,
Can any one please tell me how to iterate the above array to get the results in above pattern?
Thanks
I have 2 tables
tbl1:- id, stud_name, class_id
tbl2:-class_id, class_name
I have to display results in the below format,
class_name
student1, student2,....
The code i wrote is,
Code: Select all
$q = mysql_query("SELECT * FROM tbl1, tbl2 WHERE tbl1.class_id=tbl2.class_id");
while($r = mysql_fetch_assoc($q))
{
$stud_name = $r['stud_name'];
$class_name= $r['class_name'];
$stud_class[$class_name][]=$stud_name;
}
Thanks