Hi everyone-
I'm fairly new so please go easy on me 🙂
Here's my issue: I'm pulling data from a database and using this data to dynamically create HTML select menus. I have about 10 menus. I'm not having a problem populating the menus, but I am having a problem not displaying a menu if there is no data to populate the menu with.
Here's the code I'm using to generate/fill the menus:
<select name=rating>
<?
$pulldown_array=get_pulldown();
foreach ($pulldown_array as $thispulldown)
if (!$thispulldown['rating']=="")
{ printf ("<option value=\"%s\">%s\n", $thispulldown['rating'],$thispulldown['rating']); }
?>
</select>
The problem is that if 'rating' has no data, I still get a blank SELECT menu (because the select statement is outside of the PHP). Instead of a blank select menu, I'd prefer to just echo "No data available" or something like that. If I include the select statement inside the PHP, it gets repeated foreach.
Any ideas on how to do this?
Thanks.