★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum5/HTML/000697.htmlNouvelle recherche | Portail wanayoo
DevShed Menu
* DevShed Home
* Developer News
* DevShed Brain Dump




UBBFriend: Email This Page to Someone!
  DevShed Discussion Forums
  PHP
  Dropdown lists from a mysql db

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Dropdown lists from a mysql db
bbrown
Member
posted March 07, 2000 04:09 PM     Click Here to See the Profile for bbrown   Click Here to Email bbrown     Edit/Delete Message Reply w/Quote
Id like to load a drop down list from a mysql database using php3 and create a link to that record. Does anyone have any ideas?

codemaster
Junior Member
posted March 07, 2000 05:57 PM     Click Here to See the Profile for codemaster   Click Here to Email codemaster     Edit/Delete Message Reply w/Quote
Here is how I did it:
<SELECT NAME="category">
<?
mysql_pconnect("localhost","user","pass") or die ("unable to connect");
mysql_select_db("yourdb") or die ("cannot select db");
$opt_sql = "SELECT whatever FROM yourtable";
$opt_1 = mysql_query($opt_sql);
while($opt_2 = mysql_fetch_row($opt_1)) {
echo "<OPTION VALUE=\"" . $opt_2[0] . "\">" . $opt_2[0] . "</OPTION>\n";
}
mysql_free_result($opt_1);

?>
</SELECT>

Hope this helps.


quote:
Originally posted by bbrown:
Id like to load a drop down list from a mysql database using php3 and create a link to that record. Does anyone have any ideas?

All times are MST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | DevShed.com

Copyright © 1997-2000 ngenuity. All rights reserved.

Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.