The reason that your script goes wrong is that you:
1. fetch only one row $queryColumn from the result (you only have one mysql_fetch_xxx and not within a loop)
2. assign that row ($queryColumn) to another variable ($aData) and display the entire row (consists of 1 column only) as the option statement value and the content of the column the option statement text.
Ronald
Hello there,
I've been stuck on this problem to, could you see if im missing something in my code please. I put in the "while loop" but it returned me no values, and when I take it out I only get the first value and it repeats. I know I am close just something not there. If you could provide a example to your solution before that would be a huge help.
[PHP]<html>
<head>
</head>
<?php
$db_name="project"; // Database name
$tbl_name="bcourt"; // Table name
// Connect to server and select database.
$conn = mysql_connect($_SESSION['host'], $_SESSION['username'], $_SESSION['password'])or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
?>
<body background="main background1.jpg" link="blue" vlink="blue">
<table width="350" border="1" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="Update Network Gaming form" method="post" action="updatebcourt_ac.php">
<table width="100%" border="1" cellspacing="1" cellpadding="3">
<tr>
<td colspan="3" align="center"><strong><font face="sans-serif, Arial" font color="white">Insert Data Into mySQL Database </strong></td>
</tr>
<tr>
<td><font face="sans-serif, Arial" font color="white">Member No</td>
<td><font color="white">:</td>
<td><input name="Member_No" type="int" id="Member_No"></td>
</tr>
<tr>
<td><font face="sans-serif, Arial" font color="white">Court No</td>
<td><font color="white">:</td>
<td><input name="Court_No" type="varchar" id="Court_No" value="Bcourt"></td>
</tr>
<tr>
<td><font face="sans-serif, Arial" font color="white">Time Slot No</td>
<td><font color="white">:</td>
<td><select>
<?php
$db_name="project"; // Database name
$tbl_name="bcourt"; // Table name
// Connect to server and select database.
$conn = mysql_connect($_SESSION['host'], $_SESSION['username'], $_SESSION['password'])or die("cannot connect");
mysql_select_db("$db_name", $conn)or die("cannot select DB");
$time = "SELECT Time_Slot_No FROM $tbl_name WHERE Member_No = 'null'";
$query = mysql_query($time, $conn);
$queryColumn = mysql_fetch_array($query);
$slot = $queryColumn;
//while($queryColumn=mysql_fetch_array($query)){
foreach( $slot as $test ){
echo '<option value="' . $slot . '">' . $test . '</option>';
}
?>
</select></td>
</tr>
<td colspan="3" align="center"><input type="submit" name="Submit" value="Continue"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>[/PHP]
I do not get any errors just duplicated values which in this case is "0". My timeslots are just "0,1,2,3,4". Even if I order in DESC order it still only shows "0".
Thank you in advanced for any help.