I am importing data from a table to populate a drop down menu, is there a way to hide the drop down menu if the particular field I am importing data from is empty?
Thanks
I am importing data from a table to populate a drop down menu, is there a way to hide the drop down menu if the particular field I am importing data from is empty?
Thanks
You will have to use Javascript and use it to change the CSS visibility of the dropdown to hidden if, say, dropdownmenu.title is "EMPTY" or some other string you can pass using PHP.
The alternative is to use rewrite everything using ASP.
If you have trouble with the code, paste the bits you have trouble with and people here will help you write it up.
You could use a conditional statement to only write the html output if the sql query returns at least one row.
So kind of pseudo code:
$sqlquery = select blah
$rows = number of rows returned by $sqlquery
if $rows > 0 {
//start dropdown, note that this only happens when one row or more is returned
print <select>
for each row {
print <option>value</option>
}
print </select>
}
Easiest way I can think of would be to slap a simply if statement around your dropdown with it testing the number of rows.
If numrows!=0 -> display code for dropdown.
You can easily slide it into exsisting code without having to re-do a whole section then.
Isn't that what I've suggested in the previous post?![]()
well, print/echos are just like ending the php code, inserting plain html and then opening the php code again.
I prefer it because it keeps the code inline in a more sensible manner imo
There are currently 1 users browsing this thread. (0 members and 1 guests)