Forum Moderators: coopster

Message Too Old, No Replies

Retrieve data and display in drop down boxes

         

pancgom

3:55 am on Apr 18, 2008 (gmt 0)

10+ Year Member



Hi,

I have this form which has got all these drop down boxes which has values built in the html form, once selected they are all sent to the database table to be stored only when the authentication is done and for that record only.

I am also using the same form to retrieve information from the database and display back to the form. The problem is i am not able to display data retrieved from the database into the drop down boxes. Can someone please help me the code please.

Thanks much for the help.

<removed code dump, please see Charter [webmasterworld.com] in regards to posting guidelines>

[edited by: coopster at 6:23 pm (utc) on May 3, 2008]
[edit reason] Use example.com, thanks. [/edit]

coopster

6:25 pm on May 3, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Let's start with just the country. Are you trying to build the country drop down list from a predefined table of countries in your database? Or are you hard-coding them into your HTML?

bubbasheeko

3:11 am on May 4, 2008 (gmt 0)

10+ Year Member



I would suggest that you put your option values into your database and call the options from there. Use a while statement to go through the results of the database pull and have an if statement contained in the <option> tag.

// YOUR DB QUERY HERE

<select name="whatever">
<? while($yourqueryresults = mysql_fetch_assoc($resultsvalue)
{ ?>
<option value="<? echo $yourdbvalue; ?>" <? if($resultsoption == $pulledoption) { ?> selected <? } ?>><? echo $youroption; ?></option>
<? } ?></option>
</select>

Just a thought...may be a bit much...but it works in a pinch.