Jump to content

PHP disply query results in an HTML dropdown menu


dneimeier

Recommended Posts

I am querying a database and trying to display the names of categories in a drop-down menu.  My problem is that the names are not visible.

 

I have the following code:

 

$result = mysql_query('SELECT name FROM category') or die(mysql_error());

echo('Choose a category');

echo('<select name="category">');

echo('<option value="general" >general</option>');

while($row = mysql_fetch_array($result)){

echo('<option style="color:black;" value = "'.$row['name'].'">'.$row['name'].'</option>');

}

echo('</select><br /><br />');

 

The query is good and executing the query retrieves the expected number of results.  My dropdown box is the proper length and width (showing that it is trying to print the names); however, nothing is displayed.  Any ideas?

Link to comment
Share on other sites

Never mind.  It must have been a firefox error.  I tried to clear the cache; however, I noticed other funny things as I tried to view the source (it wouldn't show up).  After a system reboot, it works again.  WEIRD

 

Thanks for replying to me so soon - sorry to bother you with this...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.