All Modules";
$dbQuery="select * from p3_modules";
// now check for any subset codes passed in the $_GET or $_POST arrays
// first check if we want compulsory modules only
if (isset($_GET["status"]) && $_GET["status"]=="C") {
$heading="Compulsory Modules
";
$dbQuery="select * from p3_modules where status='C'";
}
// add code here to check for optional modules only (2a)
if (isset($_GET["status"]) && $_GET["status"]=="O") {
$heading="Optional Modules
";
$dbQuery="select * from p3_modules where status='O'";
}
// add code here to check for only Year 1, Year 2 or Year 4 modules (2b)
// use the LIKE operator in the query to determine the year of the module
// in the LIKE comparision, use the underscore '_' as a single character wildcard
// The 4th character of the module code determines the year
// xxx1nn for first year (e.g. COM102)
// xxx2nn for second year (e.g. ELE258)
// xxx4nn for final year (e.g. MAT425)
// if (isset($_GET["year"]) && $_GET["moduleCode"]="xxx1nn") {
if (isset($_GET["year"]) && $_GET["year"]=="1") {
$heading="Year 1 Modules
";
$dbQuery="select * from p3_modules where moduleCode='___1__'";
}
// if (isset($_GET["year"]) && $_GET["moduleCode"]="___2__") {
if (isset($_GET["year"]) && $_GET["year"]=="2") {
$heading="Year 2 Modules
";
// $dbQuery="select * from p3_modules where moduleCode='xxx2nn'";
$dbQuery="select * from p3_modules where moduleCode='___2__'";
}
// if (isset($_GET["year"]) && $_GET["moduleCode"]="___4__") {
if (isset($_GET["year"]) && $_GET["year"]=="4") {
$heading="Year 4 Modules
";
$dbQuery="select * from p3_modules where moduleCode='___4__'";
}
// code to check for computing modules
if(isset($_POST["subject"]) && $_POST["subject"]=="COM") {
$heading="Computing Modules
";
$dbQuery="select * from p3_modules where moduleCode like 'COM%'";
}
// add code here to check for electronics modules only (2c)
if(isset($_POST["subject"]) && $_POST["subject"]=="ELE") {
$heading="Electronics Modules
";
$dbQuery="select * from p3_modules where moduleCode like 'ELE%'";
}
// add code here to check for mathematics modules only (2c)
if(isset($_POST["subject"]) && $_POST["subject"]=="MAT") {
$heading="CMathematics Modules
";
$dbQuery="select * from p3_modules where moduleCode like 'MAT%'";
}
// add code here to check for modules by a particular lecturer (3b)
// now send the query
$dbResult=mysql_query($dbQuery,$db);
// display the heading and table of results
echo "$heading";
echo "".
"| Module Code | Lecturer | Status | Class Size |
";
while ($dbRow=mysql_fetch_array($dbResult)) {
$theModuleCode=$dbRow["moduleCode"];
$theLecturer=$dbRow["lecturer"];
$theStatus=$dbRow["status"];
$theClassSize=$dbRow["classSize"];
echo "| $theModuleCode | $theLecturer | ".
" $theStatus | $theClassSize |
";
}
echo "
";
?>
Choose a subject:
Choose a lecturer:
element should be the lecturer's name
// enclose the drop down list in a form with action=showModules.php
echo "";
?>