I have two slight problems I simply cant find an answer to anywhere, the first, only small.
I have my database printing out items from a database into a select box, this is giving me blank options even though there are none in the database, I remember having this problem before but cant remember how to get around it?
Secondly on the same form I would like another drop down field to change according to what is selected e.g. customer selects product, amount availible is stored in the database so I would like a qty drop down that will display from 1 upto the amount availible.
And this is the code
// connect to the server
@mysql_connect($host, $username, $password) or die ("Server is Down");
@mysql_select_db($database) or die ("Database Error");
$query="SELECT * FROM itemtbl";
$result=mysql_query($query);
$num =mysql_numrows($result);
mysql_close();
?>
<table>
<tr><td>ID</td><td>Session</td><td>Item</td><td>Date</td><td>Qty</td></tr>
<tr><td><form id="orderform" name="orderform" method="post" action=" "><input name="id" type="text" id="id" size="10"></td><td><input name="name" type="text" id="name" size="20"></td><td><select name="product" size="1">
<?php
$i=0;
while ($i < $num){
$id=mysql_result($result,$i,"itemid");
$info=mysql_result($result,$i,"info");
$price=mysql_result($result,$i,"price");
$qty=mysql_result($result,$i,"itemqty");
echo "<option value=$id> $info<option>";
$i++;
}
?>
</select>
</td><td><input name="date" type="text" id="date" size="20"></td><td><select name="qty" size="1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</td></tr>
<tr><td></td><td></td><td><input type="submit" name="submit" value="Submit"></td><td></td><td><input type="reset" name="submit2" value="Reset"></form></td></tr>
</table>
Cheers for any help