Jump to content

Cannot get this to display any results from search


misticles

Recommended Posts

The database is exampapers,

 

the tables are:

 

elements

 

course_code course_year subject sitting year link

DT205 2 Calculus/Analysis Semester 2 2006/2007 Click here

DT205 3 Classical Mechanics Semester 1 2006/2007 Click here

DT205 3 Classical Mechanics Semester 1 2007/2008 Click here

DT205 4 Integral Equations Semester 2 2006/2007 Click here

DT205 4 Differential Equations Semester 1 2006/2007 Click here

DT205 4 Differential Equations Semester 1 2007/2008 Click here

DT205 1 Computer Architecture Semester 1 2008/2009 Click here

df 3 ghgsf ssg45 2002 Click here

ds 2 uwwef sfwg45 2006 pppeagredfds

df 3 ghgsf ssg45 2002 Click here

df 1 ghgsf ssg45 2002 Click here

 

coursecodetable

 

 

courseid      course_code

    1                  dt205 

    2                  dt008

 

 

 

courseyeartable

 

yearid    courseid    course_year

    1              1                  1

    2              1                  2

    3              1                  3

    4              1                  4

    5              2                  1

    6              2                  2

    7              2                  3

 

 

The code is:

 

<?php

 

$programme = $progyear = $subjectname = $examyear = null; //declare vars

 

$conn= mysql_connect("localhost", "root", "pwrd");

$db = mysql_select_db('exampapers',$conn);

 

if(isset($_GET["programme"]) && is_numeric($_GET["programme"]))

{

$programme = $_GET["programme"];

}

 

if(isset($_GET["progyear"]) && is_numeric($_GET["progyear"]))

{

$progyear = $_GET["progyear"];

}

 

if(isset($_GET["subjectname"]) && is_numeric($_GET["subjectname"]))

{

$subjectname = $_GET["subjectname"];

}

 

if(isset($_GET["examyear"]) && is_numeric($_GET["examyear"]))

{

$examyear = $_GET["examyear"];

}

 

?>

 

<script language="JavaScript">

 

function autoSubmit()

{

var formObject = document.forms['theForm'];

formObject.submit();

}

 

</script>

 

<form name="theForm" method="get">

 

 

 

<select name="programme" onChange="autoSubmit();">

<option value="null"></option>

<option value="1" <?php if($programme == 1) echo " selected"; ?>>DT205</option>

<option value="2" <?php if($programme == 2) echo " selected"; ?>>DT008</option>

</select>

 

<br><br>

 

 

 

<?php

 

if($programme != null && is_numeric($programme))

{

 

?>

 

<select name="progyear" onChange="autoSubmit();">

<option value="null"></option>

 

<?php

 

//POPULATE DROP DOWN MENU WITH course_year FROM A GIVEN course_code

 

$sql = "SELECT DISTINCT yearid, course_year FROM courseyeartable WHERE courseid = $programme";

$progyears = mysql_query($sql, $conn);

 

while($row = mysql_fetch_array($progyears))

{

echo ("<option value=\"$row[yearid]\" " . ($progyear == $row["yearid"] ? " selected" : "") . ">$row[course_year]</option>");

}

 

?>

 

</select>

 

<?php

 

}

 

?>

 

<br><br>

 

<?php

 

if($progyear != null && is_numeric($progyear) && $programme != null)

{

 

?>

 

<select name="subjectname" onChange="autoSubmit();">

<option value="null"></option>

 

<?php

 

//POPULATE DROP DOWN MENU WITH subjects FROM A GIVEN course_code, course_year

 

$sql = "SELECT DISTINCT subject from elements WHERE course_year = $progyear ";

$subjects = mysql_query($sql,$conn);

 

while($row = mysql_fetch_array($subjects))

{

echo ("<option value=\"$row[subject]\" " . ($subjects == $row["subject"] ? " selected" : "") . ">$row[subject]</option>");

}

 

?>

 

</select>

 

<?php

 

}

 

?>

 

 

</form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.