I believe its quite a trivial task but I couldn't figure it out yet. I have a mysql table with multiple rows and columns. Each column should be used as a category for a dropdown menu. However some of those columns are shorter than the other ones. I have it currently implemented like this:
<select name="exhaust">
<option value="<? echo "$exhaust"; ?>" selected><? echo "$exhaust"; ?></option>
<?
//connect to mysql
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "SELECT * FROM tuning_parts";
$query = mysql_query($query);
//ausgabe
while($db = mysql_fetch_array($query)){
$phrase = "<option value=\"".$db['exhaust']."\">".$db['exhaust']."</option>";
echo($phrase);
};
?>
</select>
However, this give me sometimes very long dropdown lists with a lot of empty values. I've tried to play around with array_filter() but I always got empty results.
I would like to filter out the empty fields so the dropdown menu only shows actual values.