Current location: Hot Scripts Forums » General Community » Script Requests » populating a dropdown list (mysql)


populating a dropdown list (mysql)

Reply
  #1 (permalink)  
Old 09-29-06, 04:01 PM
HeX Productions HeX Productions is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Nottingham, Uk
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
populating a dropdown list (mysql)

hi guys

i want to create a dropdown list which will be populated by values in a MySQL table.

Can this be done via PHP alone or will javascript need to be involved?

hope someone can help

HP
Reply With Quote
  #2 (permalink)  
Old 09-29-06, 04:52 PM
mousegu mousegu is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
It can be done with PHP. I doubt you will find a pre-made script to do it, as it is fairly easy to do. Try searching for some tutorials.
Here is the script I wrote for my site.

PHP Code:

$sql "SELECT name,id FROM `park` ORDER BY `name` ASC";

$result mysql_query($sql) or die (mysql_error());
echo 
"<select name=\"\" id=\"\">";
while (
$row mysql_fetch_array($result)){
   
extract ($row);
   echo 
"<option value=\"$id\">$name</option>";
}
//Ends while
echo "</select>"
__________________
SSP
Professional Web Design

SSP Website

Last edited by mousegu; 09-29-06 at 04:55 PM.
Reply With Quote
  #3 (permalink)  
Old 09-30-06, 04:57 AM
HeX Productions HeX Productions is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Nottingham, Uk
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
sound! - works like a charm!

Cheers

HP
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Field Names into PHP Dropdown Menu KaraJ PHP 4 06-14-05 09:28 AM
Can I populate a dropdown list???? zorrox02 JavaScript 4 10-01-04 04:03 AM
Calling MYSQL table & list entrys in dropdown menu doublee313 PHP 1 09-25-04 04:29 AM


All times are GMT -5. The time now is 11:28 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.