PDA

View Full Version : displaying data from a database into a drop down list


debcous
08-21-2006, 02:26 PM
hi

can anyone please help me?? i'm trying to pull data from my database and display this data in a drop down list. I have 3 drop down menus, when a sourcre is selected in the first menu...only the destinations available from that source should be displayed in the 2nd drop down and then the destinations of the next selection displayed in the 3rd drop down. If anyone knows how to do this can they please help me

Thanks,
Debbie

Fumigator
08-21-2006, 03:19 PM
If the number of options these selects have is fairly small then I would dump the database info into Javascript arrays (by inserting <?php ?> tags inside Javascript code) and use Javascript to dynamically change the options in the select boxes. Reloading the page to select data out of the database every time a selection is made would cause a delay that could be avoided by using this method.

Anthony2oo4
08-21-2006, 09:14 PM
I just finished making one of these for my own site, maybe u cna see what i did and make your own:

$resultQS = $db->sql_query("SELECT c.cat_id, f.forum_name, f.forum_id FROM cms_bbcategories c, cms_bbforums f WHERE f.cat_id = c.cat_id ORDER BY c.cat_id, f.forum_order",false,__FILE__,__LINE__);
$numQS = $db->sql_numrows($resultQS);

$content = '<form action="Forums/search/mode=results.html" method="post" enctype="multipart/form-data" accept-charset="utf-8">
<input type="text" style="width: 100px" class="post" name="search_keywords" size="30" /><br>
<select class="post" name="search_forum">
<option value="-1">All available</option>';

$iQS=0;
while ($iQS < $numQS) {
$name = mysql_result($resultQS,$iQS,"forum_name");
$value = mysql_result($resultQS,$iQS,"forum_id");

$content .= '<option value="'.$value.'">'.$name.'</option>';

$iQS++;
}

Note that my site has some built in functions that i used in there so for you to get the data from the database ur query is going to be different and also the way u ge it from the database.

You mainly want to concentrate on the while loop.