Reputation: 177
I want to use the following code to populate a drop-down list with all of the customer types:
<select name="type" id="type" class="neutral">
<?php // SQL QUERY TO RETRIEVE EVERY TYPE OF CUSTOMER
$sql = "SELECT CUST_TYPE FROM `CUSTOMER` GROUP BY `CUST_TYPE`";
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)){echo '<option value="'.$row.'">'.$row.'</option>';}
?>
The query works in phpMyAdmin; it gives the correct output (corporate, other, school, sports) but in the webpage it displays a drop-down list with 4 options, all containing the word "array." Please help!
Upvotes: 0
Views: 4323
Reputation: 1131
Try
while($row = mysql_fetch_assoc($result)){
echo '<option value="'.$row['CUST_TYPE'].'">'.$row['CUST_TYPE'].'</option>';
}
Upvotes: 2