I tried this and didnt have much luck:
<?
if (!$_POST) {
?>
<form method="POST" 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['NAME']), htmlentities($row['NAME']));
}
}
?>
</select>
<input type="submit" />
</form>
<?
} elseif ($_POST['teacherchoice']) {
?>
<form method="POST" action="test2.php">
<select name="Teacher_Name">
<?
// Connect to DB
$conn = ociLogon("K2DEV", "K2DEV", "SBV3");
// This is the SQL statement to run
$query = "SELECT * FROM teachers 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</option>\n", htmlentities($row['First_Name']), htmlentities($row['First_Name']));
}
}
?>
</select>
<input type="submit" />
</form>
<?
} elseif ($_POST['teacherchoice']) {
?>
<form method="POST" action="test2.php">
<select name="studentchoice">
<?
// Connect to DB
$conn = ociLogon("K2DEV", "K2DEV", "SBV3");
// This is the SQL statement to run
$query = "SELECT * FROM students 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</option>\n", htmlentities($row['First_Name,Last_Name']), htmlentities($row['First_Name,Last_Name']));
}
}
?>
</select>
<input type="submit" />
</form>
<?
} elseif ($_POST['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...
}
?>
Thanks again for your help