Convert database values into Dropdown List

Thread Solved

Join Date: Mar 2007
Posts: 5
Reputation: JSR is an unknown quantity at this point 
Solved Threads: 0
JSR JSR is offline Offline
Newbie Poster

Convert database values into Dropdown List

 
0
  #1
Mar 8th, 2007
Hi Guys, new to this forum, kinda new to PHP in general haven't been using it long, mostly creating forms for database and custom CMS modules.

Anyway, i'm building a html email tool from the ground up and just need some help with one thing.

How do i convert values from a database field into a html form drop-down list?

I want to make a the list that display individual users and if you select a user, the value becomes that users email address
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 232
Reputation: Rhyan is an unknown quantity at this point 
Solved Threads: 24
Rhyan's Avatar
Rhyan Rhyan is offline Offline
Posting Whiz in Training

Re: Convert database values into Dropdown List

 
0
  #2
Mar 8th, 2007
Originally Posted by JSR View Post
Hi Guys, new to this forum, kinda new to PHP in general haven't been using it long, mostly creating forms for database and custom CMS modules.

Anyway, i'm building a html email tool from the ground up and just need some help with one thing.

How do i convert values from a database field into a html form drop-down list?

I want to make a the list that display individual users and if you select a user, the value becomes that users email address
Such an action is created easier with Javascript. Still you can do it with php, but after clicking on the drop-down menu, the form will be submited and code revalidated in order to show the value you expect.

If you want to know how to create the drop down menu using php - go through the threads from last week - I think there is at least 2 posts with the same problem. For the JS script - it is a completely different story.

Good luck.
" Of all the things I've lost,
I miss my mind the most...."
Mark Twain
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,082
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Convert database values into Dropdown List

 
0
  #3
Mar 11th, 2007
Originally Posted by JSR View Post
Hi Guys, new to this forum, kinda new to PHP in general haven't been using it long, mostly creating forms for database and custom CMS modules.

Anyway, i'm building a html email tool from the ground up and just need some help with one thing.

How do i convert values from a database field into a html form drop-down list?

I want to make a the list that display individual users and if you select a user, the value becomes that users email address
Theres two things you'll need to know.


1) How to Query the Database with PHP.
2) The structure of the HTML <select> field (drop-down list)


Assuming you're using MySQL database, look here for the functions:
http://php.net/mysql

Lets say you have a Table: Users with columns username, and email

The SQL to select usrs and email would be:

[PHP]$sql = "select username, email from Users LIMIT 10";[/PHP]


The Structure of the HTML <select> is:

[PHP]
<select name="box_name" id="box_id">

<option value="value1">Label 1</option>
<option value="value2">Label 2</option>

</select>[/PHP]


You'll probably want to generate something like:

[PHP]<select name="user_email" id="user_email">

<option value="email1">User Name 1</option>
<option value="email2">User Name 2</option>

</select>[/PHP]
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 5
Reputation: JSR is an unknown quantity at this point 
Solved Threads: 0
JSR JSR is offline Offline
Newbie Poster

Re: Convert database values into Dropdown List

 
0
  #4
Mar 13th, 2007
Thanks for the help digital-ether, got it working.
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,082
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: Convert database values into Dropdown List

 
0
  #5
Mar 13th, 2007
You're welcome.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC