Page 1 of 1
get data from database and display it in a drop-downlist box
Posted: Mon Sep 08, 2008 9:19 am
by zplits
Hello there everyone. Good day. Does anyone here know how to get data from the database and display it in the drop-down list box? What will be the code?
Here is my database info:
table name : supplies
fields:
supplies_PK
code
name
price
here is the code for html drop-down list
Code: Select all
<select name="[b][color=#BF0000]code[/color][/b]" size="1" class="formFieldsDropDownCode" id="code" tabindex="4">
and here is the screenshot:
Please help me. Thank you very much.
Re: get data from database and display it in a drop-downlist box
Posted: Mon Sep 08, 2008 9:33 am
by jaoudestudios
Just do a query and put a while loop around the html code for the select options.
Re: get data from database and display it in a drop-downlist box
Posted: Mon Sep 08, 2008 9:42 am
by zplits
Thanks for the response. Can you please provide the code? I'm sorry. I'm new in php. I hope you understand. Thanks a lot.
Re: get data from database and display it in a drop-downlist box
Posted: Mon Sep 08, 2008 10:05 am
by Stryks
First, come up with a query to pull all the values you want to list from the database.
Then look at the HTML for a select and take note of the tags that would need to be added to insert an option to the list.
Then, loop through the options returned by your query, just like you did for displaying rows of data elsewhere, and on each loop, echo the HTML and values that will add the options needed to the final markup.
Give it a shot, and if you have any trouble ... take a look at the HTML source you are producing. See if you can see what isn't showing up the way it should, and what you can do to make it behave.
Cheers