Page 1 of 1
Access Database from Dropdown list
Posted: Fri Nov 17, 2006 8:45 am
by cjan1234
Newbie Here!!!!
When I click on a selection from a dropdown list I need to access information stored in a database and echo that information on the same page as the dropdown list.
Any help would be appreciated.
Thanks,
Dropdown
Posted: Fri Nov 17, 2006 8:53 am
by timclaason
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
You could do something like this:
Code: Select all
<FORM METHOD="POST" ACTION="whateverpage.php">
<TABLE>
<TR>
<TD>Dropdown List</TD>
<TD><SELECT SIZE='1' NAME='dropdownlist'>
<OPTION>Click in this dropdown list</OPTION>
<!--Start PHP Code-->
$query = "SELECT * FROM table"; //or whatever the query is
$SQL = mysql_query($query, $db_link);
while($row = mysql_fetch_array($SQL)) {
print("<OPTION>" . $row['field_from_table'] . "</OPTION>");
}
<!--End PHP Code-->
</SELECT></TD>
</TR>
</TABLE>
<INPUT TYPE='SUBMIT' VALUE='Submit'>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Thanks timclaason
Posted: Fri Nov 17, 2006 9:08 am
by cjan1234
Thanks, I will try that