LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-14-2004, 07:12 PM   #1
Gerardoj
Member
 
Registered: May 2003
Location: Somewhere over the Rainbow
Distribution: Slackware 9.x, Knoppix, Damn Small Linux, RedHat.
Posts: 465

Rep: Reputation: 30
PHP code and DropDown Menu


Hi. I would to know how can I fill a drop down menu with a table data of a mySQL DataBase.?. Thanks a lot..
 
Old 04-14-2004, 11:22 PM   #2
bigredgiant1
Member
 
Registered: Aug 2003
Distribution: Redhat since 5.2, Gentoo
Posts: 43

Rep: Reputation: 15
Code:
<?php
$fp = mysql_connect("localhost","username","password");
mysql_select_database("databasename");

$sql = "
SELECT *
FROM someTable
WHERE something = \"".$someVar."\"
";

if(!($result = mysql_query($sql))) {
    echo "No dice.";
} else {
    echo "<select name=\"myDropDownList\">";
    while($row = mysql_fetch_array($result)) {
         echo "<option value=\"".
              $row['someField']."\">".$row['someOtherField']."</option>";
    }
    echo "</select>";
}

?>
 
Old 04-15-2004, 02:53 AM   #3
Gerardoj
Member
 
Registered: May 2003
Location: Somewhere over the Rainbow
Distribution: Slackware 9.x, Knoppix, Damn Small Linux, RedHat.
Posts: 465

Original Poster
Rep: Reputation: 30
Thanks a lor. That was what I looking for..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add shorcut to Kmenu and gnome menu via perl code mf1234 Linux - Software 0 08-15-2005 12:18 PM
KDM Dropdown Menu Font bill.ramby Linux - Software 2 03-29-2005 03:20 PM
CXOFFICE dropdown menu glitch TuxFreak Linux - Software 0 03-12-2005 07:03 PM
php: display timestamp in editable dropdown box? opioid Programming 5 07-28-2004 04:33 PM
PHP Dropdown menu agallant Programming 1 06-10-2004 01:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration