I have a php code that forms a dropdown using a mysql table. I am using the dropdown to search and filter results in a page. The problem that I have is that it only shows the values from the table, I also need an option where I can leave the dropdown blank. For example the values be a,b,c,d but if I do not want any of these options I want the dropdown left blank. Any ideas on how to do this? Thanks in advance for the help.

Here is the php code:
[<td>Program:</td><td>
<?php echo "<select name=formdata[Program_val] default value='Null' >Program</option>";
// printing the list box select command

while($nt=mysql_fetch_array($result)){//Array or records stored in $nt

echo "<option value=''$nt[ProgramId]>$nt[Program]</option>";
}]

Recommended Answers

All 4 Replies

<select name=formdata[Program_val] default value='Null' >Program</option>

Should be this.

<select name='formdata[Program_val]'>
    <option value='Null' selected='selected'>Program</option>
<option value=''>--select--</option>

Thank you so much, this is exactly what I needed!

one way of saying thanks is marking this thread solved.. :twisted:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.