Situation (simplified):
mysql database with following fields:
- product: 10,11,12,13
- type: shirt
- size: s, m, l, xl
Try to group above data by type into an option list.
Code (simplified)
define("SQL", "SELECT `product`, `type` , `size`, FROM `products` ORDER BY `type` ASC");
$sql = mysql_query(SQL) or die(mysql_error());
while ($result = mysql_fetch_assoc($sql)) {
foreach($result as $result["type"]) {
echo '<li>' . $result["product"] . '<br />';
echo '<br /><select name="size">';
echo '<br /><option value=" ' . $result["size"] . '">' . $result["size"] . '</option>\n';
echo '</select>';
echo '</li>';
}
}
the foreach loop is not correct, I know since the output fron this code is not correct. Is there another statement I could use for this situation?
Regards,
Enno










Bookmarks