I am new to PHP so I could do with some help as I am stuck.
I have set up a table, with 6 fields, in a MYSQL database some fields are blank.
I have been able to populate a seperate Drop Down menu in PHP for each field, code used is
<select name="county">
<?php
$sql_result = mysql_query("SELECT * FROM userdata");
echo "<option>Select</option>";
if(mysql_num_rows($sql_result))
{
while($row = mysql_fetch_assoc($sql_result))
{
echo "<option value=\"$row[county]\">$row[county]</option>";
}
}
?>
</select>
The problem is the drop down has all the blanks in as well and I only want the fields which have something in.
I know I can just create 6 individual tables but wondered if there is a way to display all fileds, which are not empty, in a drop down.
Can anyone help.
Thanks
tuscan