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,
Access Database from Dropdown list
Moderator: General Moderators
-
timclaason
- Forum Commoner
- Posts: 77
- Joined: Tue Dec 16, 2003 9:06 am
- Location: WI
Dropdown
feyd | Please use
feyd | Please use
Code: Select all
,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
,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
Thanks, I will try that