claro Posted October 23, 2011 Share Posted October 23, 2011 These things are new to me. I want to put these values foreach ($_POST['course'] as $course) { $c = mysql_query ("SELECT course_Id FROM tbl_course WHERE course_Title = '$course' ") or die (mysql_error()); while ($row2 = mysql_fetch_array ($c)) { echo $row2['course_Id']."<br/>"; } } foreach ($_POST['program'] as $prog ) { $p = mysql_query ("SELECT * FROM tbl_user WHERE user_Program = '$prog'") or die (mysql_error()); while ($row = mysql_fetch_array ($p)) { echo $row['user_Id']." ".$row['user_Fname']."<br/>"; } } to my queries below . $stud = mysql_query ("SELECT * FROM vw_report_instructor WHERE user_Id = '$user_Id'") or die (mysql_error()); while ($row = mysql_fetch_array ($stud)) { $courseid = $row['course_Id']; $seid = $row['se_Id']; $userid = $row['user_Id']; $name = mysql_query("SELECT user_Fname, user_Lname , user_Program FROM tbl_user WHERE id = '$userid' and user_Program = '$prog '") or die (mysql_error()); while ($row2 = mysql_fetch_array($name)) { $fullname = $row2['user_Fname']." ".$row2['user_Lname']; $program = $row2['user_Program']; $course = mysql_query ("SELECT course_Title FROM tbl_course WHERE course_Id = '$courseid'") or die (mysql_error()); while ($row3 = mysql_fetch_array($course)) { $course = $row3['course_Title']; $year = mysql_query ("SELECT se_Yearlevel FROM tbl_studenroll WHERE se_Id = '$seid'") or die (mysql_error()); while ($row4 = mysql_fetch_array ($year)) { $fullname = $row2['user_Fname']." ".$row2['user_Lname']; $program = $row2['user_Program']; $year = $row4['se_Yearlevel']; echo "<tr><td>".$fullname."</td>"; echo "<td>".$course."</td>"; echo "<td>".$year."</td>"; echo "<td>".$program."</td></tr>"; } } } $user_Id can be found in my first query, while $prog in second . Quote Link to comment https://forums.phpfreaks.com/topic/249650-im-dead-branching-foreach-and-queries/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.