Hi All
I spent alot of time getting this to work.
In the page where a student will input his student number to register for a course. I wanted a dynamic dropdown list reading all courses from the database table course. I got it working with the variable of course posted to the database.
My problem is that I dont want the course name posted i want the cid number posted. I know i have to put a select statement for the cid where cname = cname, but where do i put the select statement.
<?php require_once('Connections/Test.php'
; ?>
<?php
mysql_select_db($database_Test, $Test);
$query_DropDown = "SELECT * FROM course ORDER BY cname ASC";
$DropDown = mysql_query($query_DropDown, $Test) or die(mysql_error());
$row_DropDown = mysql_fetch_assoc($DropDown);
$totalRows_DropDown = mysql_num_rows($DropDown);
?><?php
include("C:\WebServer\FoxServ\www\UNISAProject\header.php"
;
//print_r($_POST);
$link = mysql_connect("localhost"
or
die ("Connection to the MYSQL Server was unsuccessfull"
;
mysql_select_db('UniversityDatabase'
or
die ("Cannot connect to the UniversityDatabase"
;
?>
<form method=post action='Update_Course_Registrations.php'>
<html>
<head>
<title>Student Registration Form</title>
</head>
<body>
<tr>
<td width="262"><p>Enter Name of Course
Course
<select name="select">
<option value="value" <?php if (!(strcmp("value", $row_DropDown['cname']))) {echo "selected=\"selected\"";} ?>></option> <?php
do {
?> <option value="<?php echo $row_DropDown['cname']?>"<?php
if (!(strcmp($row_DropDown['cname'], $row_DropDown['cname'])))
{echo "selected=\"selected\"";} ?>>
<?php echo $row_DropDown['cname']?>
</option> <?php }
while ($row_DropDown = mysql_fetch_assoc($DropDown));
$rows = mysql_num_rows($DropDown);
if($rows > 0) {
mysql_data_seek($DropDown, 0);
$row_DropDown = mysql_fetch_assoc($DropDown);
}
?> </select>
</p>
</tr>
<tr>
<td>Enter your Student Number
<input name='Student_number' type='text'></td>
<td> </td>
</tr>
<p align="center"> </p>
<form name="form1" method="post" action="">
<input type="submit" name="Submit" value="Submit">
</form>
<p align="center"> </p>
</body>
</html>
<?php
mysql_free_result($DropDown);
?>