dalecosp helped me alot in getting this thing going.....(Thanks if you read this) ..... My trouble now is how do i pass the variable from the first drop down (schoolchoice) to display on the third drop down (student drop down).....Code is below... Once i select one item i want to show it static above the next drop down...As you can see I can display the school choice on the teacher drop down and the teacher choice on the student drop down but i dont know how to display the school choice on the student drop down.....(passing from school choice to teacher to student)
<?
ini_set('session.use_trans_sid', false); session_start();
require('include/general.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Testing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?
if (!$_GET) {
?>
<!-- Here is where we start the first form.....the school drop down menu -->
<form method="GET" action="test2.php">
<select name="schoolchoice">
<?
// Connect to DB
$conn = ociLogon("K2DEV", "K2DEV", "SBV3");
// This is the SQL statement to run
$query = "SELECT * FROM schools ORDER by Name";
// This parses the SQL Statement for use
$statement = OCIParse($conn, $query);
// OCIExecute returns true/false if the query succedded in runnin
// Note that this does NOT COMMIT by default, if you are using INSERT/UPDATE/DELETE
if(OCIExecute($statement))
{
// oci_fetch_array() returns the next row from the result set, OCI_BOTH returns tuples as both associative array
// eg, '$row['NAME']' and indexed array, eg $row[1].
// You can also use oci_fetch_assoc() for just an associative array, or oci_fetch_row() for just numeric array
// Oracle returns all field names in UPPERCASE, so your associative array's will be indexed as such as well.
while(OCIFetchInto($statement, $row, OCI_ASSOC))
{
printf("<option value='%s'>%s</option>\n", htmlentities($row['SCHOOL']), htmlentities($row['NAME']));
}
}
?>
</select>
<input type="submit" />
</form>
<?
}
elseif ($_GET['schoolchoice'])
{
?>
<!-- Here is where we display the school choice static on the teacher choice page -->
<?
//connect to the db
$conn = ociLogon("K2DEV", "K2DEV", "SBV3");
//bring over schoolchoice variable
$schoolchoice=$_GET['schoolchoice'];
//run new query to print schoolchoice on teacherchoice page
$query = "SELECT A.LAST_NAME,A.FIRST_NAME,A.TEACHER_ID,B.NAME
FROM teachers A, Schools B
WHERE B.SCHOOL = A.SCHOOL
AND A.SCHOOL = '$schoolchoice'";
// This parses the SQL Statement for use
$statement = OCIParse($conn, $query);
// OCIExecute returns true/false if the query succedded in runnin
// Note that this does NOT COMMIT by default, if you are using INSERT/UPDATE/DELETE
if(OCIExecute($statement))
//this starts a flag.....so that it will only display the name one time
{ $flag = '0';
while(OCIFetchInto($statement, $row, OCI_ASSOC))
{
if($flag == 0){
?>
<b>
<?
printf('%s', htmlentities($row['NAME']), htmlentities($row['NAME']));
$flag = 1;
}
}
}
//this ends the flag....name should have only printed once on the teacher choice page....
?>
</b>
<!-- Here is where we start the form for the teacher choice drop down menu..... -->
<form method="GET" action="test2.php">
<select name="teacherchoice">
<?
// Connect to DB
$conn = ociLogon("K2DEV", "K2DEV", "SBV3");
// This is the SQL statement to run
//$schoolchoice=$_GET['schoolchoice'];
$query = "SELECT A.LAST_NAME,A.FIRST_NAME,A.TEACHER_ID,B.NAME,B.SCHOOL
FROM teachers A, Schools B
WHERE B.SCHOOL = A.SCHOOL
AND A.SCHOOL = '$schoolchoice'";
// This parses the SQL Statement for use
$statement = OCIParse($conn, $query);
// OCIExecute returns true/false if the query succedded in runnin
// Note that this does NOT COMMIT by default, if you are using INSERT/UPDATE/DELETE
if(OCIExecute($statement))
{
// oci_fetch_array() returns the next row from the result set, OCI_BOTH returns tuples as both associative array
// eg, '$row['NAME']' and indexed array, eg $row[1].
// You can also use oci_fetch_assoc() for just an associative array, or oci_fetch_row() for just numeric array
// Oracle returns all field names in UPPERCASE, so your associative array's will be indexed as such as well.
while(OCIFetchInto($statement, $row, OCI_ASSOC)){
printf("<option value='%s'>%s, %s</option>\n", htmlentities($row['TEACHER_ID']), htmlentities($row['LAST_NAME']),htmlentities($row['FIRST_NAME']));
}
}
?>
</select>
<input type="submit" />
</form>
<?
}
elseif ($_GET['teacherchoice'])
{
?>
<!-- Here is where we display the teacher choice static on the student choice page -->
<?
//connect to the db
$conn = ociLogon("K2DEV", "K2DEV", "SBV3");
//bring over teacherchoice variable
$teacherchoice=$_GET['teacherchoice'];
//run new query to print teacherchoice on studentchoice page
$query = "SELECT A.LAST_NAME,A.FIRST_NAME,A.TEACHER_ID,B.NAME,B.SCHOOL
FROM teachers A, Schools B
WHERE B.SCHOOL = A.SCHOOL
AND A.TEACHER_ID = '$teacherchoice'";
// This parses the SQL Statement for use
$statement = OCIParse($conn, $query);
// OCIExecute returns true/false if the query succedded in runnin
// Note that this does NOT COMMIT by default, if you are using INSERT/UPDATE/DELETE
if(OCIExecute($statement))
//this starts a flag.....so that it will only display the name one time
{ $flag = '0';
while(OCIFetchInto($statement, $row, OCI_ASSOC))
{
if($flag == 0){
?>
<b>
<?
printf("<option value='%s'>%s, %s</option>\n", htmlentities($row['TEACHER_ID']), htmlentities($row['LAST_NAME']),htmlentities($row['FIRST_NAME']));
$flag = 1;
}
}
}
//this ends the flag....name should have only printed once on the student choice page....
?>
<!-- Here is where we start the drop down menu form for the student choice based on the
teacher chosen in the previous drop down menu -->
<form method="GET" action="test2.php">
<select name="studentchoice">
<?
// Connect to DB
$conn = ociLogon("K2DEV", "K2DEV", "SBV3");
// This is the SQL statement to run
$teacherchoice=$_GET['teacherchoice'];
$query = "SELECT A.STUDENT_ID, A.LAST_NAME, A.FIRST_NAME
FROM students A, teachers B, stu_enr C
WHERE A.STUDENT_ID = C.STUDENT_ID
AND C.SCHOOL = B.SCHOOL
AND C.HOMEROOM = B.HOMEROOM
AND B.TEACHER_ID = '$teacherchoice'
ORDER BY LAST_NAME ";
// This parses the SQL Statement for use
$statement = OCIParse($conn, $query);
// OCIExecute returns true/false if the query succedded in runnin
// Note that this does NOT COMMIT by default, if you are using INSERT/UPDATE/DELETE
if(OCIExecute($statement))
{
// oci_fetch_array() returns the next row from the result set, OCI_BOTH returns tuples as both associative array
// eg, '$row['NAME']' and indexed array, eg $row[1].
// You can also use oci_fetch_assoc() for just an associative array, or oci_fetch_row() for just numeric array
// Oracle returns all field names in UPPERCASE, so your associative array's will be indexed as such as well.
while(OCIFetchInto($statement, $row, OCI_ASSOC))
{
printf("<option value='%s'>%s, %s</option>\n", htmlentities($row['STUDENT_ID']), htmlentities($row['LAST_NAME']),htmlentities($row['FIRST_NAME']));
}
}
?>
</select>
<input type="submit" />
</form>
<?
}
elseif ($_GET['studentchoice'])
{
// now you do some real stuff, but you haven't said what ...
// maybe you redirect to another page? ;-)
}
else
{
// there's something wrong, so give an error message here...
}
?>
</body>
</html>
Thanks in advance for any help....