<select>
<?
$sql_model = "SELECT asset_types.AssetType, models.AssetTypeID, models.Model FROM asset_types INNER JOIN models ON asset_types.AssetType = models.AssetTypeID ORDER BY AssetType, Model";
$result_model = mysql_query($sql_model);
$group_model = array();
while ($row_model = mysql_fetch_assoc($result_model))
{
$group_model[$row_model['AssetType']][] = $row_model;
}
foreach ($group_model as $key => $values)
{
echo '<optgroup label="'.$key.'">';
foreach ($values as $value)
{
echo '<option value="'.$value['Model'].'"> '.$value['Model'].' </option>';
}
echo '</optgroup>';
}
?>
</select>
|