Can someone please tell me what I am doing wrong. I'm trying to create a drop down lost from a database.
Here is my code:
<?
//Choose products
?>
<table border="1">
<th colspan="2">Please choose the products below and the quantity with which you wish to create a purchase order</th>
<tr>
<td><strong>Item Name </strong></td>
<td><strong>Quantity to Order</strong></td>
</tr>
<?
$vendors = "_vendors";
$company2 = $company;
$company2 = eregi_replace(' ', "_", $company2);
$company_vendors = $company2 . $vendors;
//Get the vendor information
$vendortag = $id;
$vendorinfo = mysql_query("SELECT * FROM $company_vendors WHERE vendorid=$id") or die (mysql_error());
$vendor_name = $vendorinfo['name'];
//Display the items in a drop down box.
?>
<tr>
<td>
<select name="item1">
<option value="none" selected> N/A
<?
$item_list = mysql_query("SELECT * FROM $company WHERE vendor=$vendor_name") or die (mysql_error());
while($row1 = mysql_fetch_row( $item_list )) {
$item_name = $row1['item_name'];
echo "<option value=$item_name>$item_name</option>";
}
?>
</select>
<td>
<input size="5" name="item1qty" id="item1qty">
</td>
</tr>
</table>
<?
} ?>
The error is inside the drop list, I'll copy straight from View Source:
<select name="item1">
<option value="none" selected> N/A
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Thanks in advance,
Johnie Karr
Church of Christ
www.godsbible.org