I want the list box's contents to change based upon the contents of the DB. So if someone purchased a unit, the DB would have only 4 remaining and the listbox would be shortened to 4 options from 1 to 4.
Following is my code for the listbox. Can you see and problems or offer any suggestions? Thank you.
Code: Select all
<?php
$qtyE1 = mysql_query("select qty from dtzr0001_inventory where item = 'E1'");
$qtyE2 = mysql_query("select qty from dtzr0001_inventory where item = 'E2'");
$qtyE3 = mysql_query("select qty from dtzr0001_inventory where item = 'E3'");
$qtyE4 = mysql_query("select qty from dtzr0001_inventory where item = 'E4'");
echo "<select> size=";
echo "1";
echo "name=";
echo "lstQty1";
echo "onChange=";
echo "calculate(this.name, this.selectedIndex)>";
echo "<option selected=";
echo "selected";
echo ">-</option>";
$startindex = 0;
$select=array();
$count = $qtyE1;
for($i = 1; $i $count; $i++)
{
$select=array_fill($startindex,1,$i);
$startindex = $startindex + 1;
}
while(list($key,$value)=each($select))
{
echo "<option>$value</option>";
}
?>