dannyone Posted February 20, 2009 Share Posted February 20, 2009 hello everyone, currently i have a drop down menu that displays all the students that the logged in marker is teaching. now i want the marker to be able to select the student that they are marking from the list and once selected view the timetable for that student. its seems really complicated, and i have been working on it for a while now, so if any1 could help it'd be brilliant! heres my code so far: <?php require_once('auth1.php'); require_once('config.php'); ?> <h4><?php echo $_SESSION['SESS_FIRST_NAME'], " ".$_SESSION['SESS_LAST_NAME'];?>, the students you are marking are;</h4> <form action="" method="POST"> <?php //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //query for the combo box $query="SELECT Student,FName,LName FROM Student_Markers,Student WHERE Student_Markers.Student = Student.Student_ID AND Marker1 = '" .$_SESSION['login'] . "'"; $result = mysql_query ($query); echo "<select Student=Student value=''>Student</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){ //Array or records stored in $nt echo "<option value=$nt[student]>$nt[student], $nt[FName], $nt[LName]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> <input type="submit" value="View Timetable and Details" /> viewing the student timetable <?php // Create an array of days $days = array('mon' => '', 'tue' => '', 'wed' => '', 'thu' => '', 'fri' => ''); // Add our list of days to our time slots $times = array( '9-10' => $days, '10-11' => $days, '11-12' => $days, '12-1' => $days, '1-2' => $days, '2-3' => $days, '3-4' => $days); // Connect to DB and run our query $sql = new mysqli('localhost', 'danny', 'danny', 'tutorial'); $run = $sql->query("SELECT s.Student_ID, c.course_id, c.time_slot, c.RoomName, c.Semester_ID, c.day FROM Student AS s INNER JOIN Student_Course AS sc ON (s.Student_ID = sc.Student_ID) INNER JOIN Course AS c ON (c.course_id = sc.course_id) INNER JOIN Student_Markers AS sm ON (sc.Student_ID = sm.Student) WHERE sm.Student = '$nt' AND c.Semester_ID = 'Semester1'"); while($row = $run->fetch_object()) { $times[$row->time_slot][$row->day] = "$row->course_id<br />$row->RoomName"; } $body = <<< endBody <center> <table align="center" border="1" cellspacing="0" cellpadding="1"> <tr> <th align="center">Time</th> <th align="center">Monday</th> <th align="center">Tuesday</th> <th align="center">Wednesday</th> <th align="center">Thursday</th> <th align="center">Friday</th> </tr> endBody; // For each time slot, check each day for a value // If one exists, display it, if not, display an empty table data (<td>) foreach($times as $timeslot => $day) { $body .= "\n\t\t<tr>\n\t\t\t<td>$timeslot</td>"; foreach($day as $course) { $td = (strlen($course) > 0) ? $course : ' '; $body .= "\n\t\t\t<td>$td</td>"; } $body .= "\n\t\t</tr>"; } $body .= "\n\t</table>\n</center"; ?> <?=$body?> thanks Danny Link to comment https://forums.phpfreaks.com/topic/146152-storing-and-using-a-combo-box-value/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.