954,591 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Convert database values into Dropdown List

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

JSR
Newbie Poster
5 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

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.

Rhyan
Posting Whiz in Training
240 posts since Oct 2006
Reputation Points: 21
Solved Threads: 26
 

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 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 is:

[PHP]
Label 1Label 2[/PHP]


You'll probably want to generate something like:

[PHP]User Name 1User Name 2[/PHP]

digital-ether
Nearly a Posting Virtuoso
Moderator
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
 

Thanks for the help digital-ether, got it working.

JSR
Newbie Poster
5 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

You're welcome. :)

digital-ether
Nearly a Posting Virtuoso
Moderator
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
 

can u explain me what exactly does d keywords like box_name , value1 n all mean"? m a fresher . n m not able to understand

sush.princess
Newbie Poster
1 post since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You