I am trying to print a list of information in a form from a database. The information i am wanting to print depends on the results from some froms and the takes a value from one table and the uses this value to find information from another table. is it possible to write a querey like this in SQL or do i need to use a loop in php to get the information. I have done the following php loops to try and do this but it doesn't seem to work and i can't make it work in a single SQL querey.
$x = $_POST[mod];
$y = $_POST[course];
$z = $_POST[sel_gp];
$get_list5 = "select stuid from student_group where stumg = '$z'";
$get_list_res5 = mysql_query($get_list5) or die(mysql_error());
while ($recs = mysql_fetch_array(get_list_res5)){
$group = $recs['stuid'];
$get_list6 = "select concat_ws(firstname, secondname) as display_name from student where stuid = $group";
$get_list_res6 = mysql_query($get_list6);
while ($recs2 = mysql_fetch_array(get_list_res6)){
$name = $recs2['display_name'];
$display_block .="$name";
}
}
Does anyone have any ideas for the best way for me to go about this??
much appriciated
$x = $_POST[mod];
$y = $_POST[course];
$z = $_POST[sel_gp];
$get_list5 = "select stuid from student_group where stumg = '$z'";
$get_list_res5 = mysql_query($get_list5) or die(mysql_error());
while ($recs = mysql_fetch_array(get_list_res5)){
$group = $recs['stuid'];
$get_list6 = "select concat_ws(firstname, secondname) as display_name from student where stuid = $group";
$get_list_res6 = mysql_query($get_list6);
while ($recs2 = mysql_fetch_array(get_list_res6)){
$name = $recs2['display_name'];
$display_block .="$name";
}
}
Does anyone have any ideas for the best way for me to go about this??
much appriciated