Hi all,
I'm having problems getting my multi-select list populated from a mysql
table. There is a table called categories with 2 columns (id and category).
I want to get all the items (category) and list them in the multi-select
list box.
This is the code I have so far:
$sql = "SELECT category FROM categories";
$result = mysql_query($sql, $connection);
//Try This instead of the while statement
foreach($result as $row) {
echo '<OPTION VALUE="' . $row['category'] . '">' . $row['category'];
}
echo '</select>';
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$category = $row['category'];
$category_list .= "$category";
}
?>
<select name=category_list_array[] multiple size=10>
<?
for ($i=0; $i<count($category_list); $i++) {
?>
<option value=<?=$category_list[$i]?>><?=$category_list[$i]?></option>
<?}?>
</select>
Now, if I echo $category_list to the page I can see I have the correct data,
I just can't get it into the list box. I've seem to hit a wall on any
different ways to try and make this work. What am I doing wrong?
Thanks.
Rob.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php