hey guys i was woundering if it was possible to connect and grab infromation from a database triggered by a drop down menu click in php .... or will i have t o learn java and figure it out there .. im sure there is a way tho somone help meo ut im new to php ;)

Yes this is a smiple way but when your data become too important, you may wish to use Ajax combined with your menu. This way you can make calls to your server which gives back the data requested.

Here is an examlpe of how I used a dynamic select box using PHP.

In this case I have a table called "facilities" and display the information in the select options by calling the information from the db.
I further set the variable "$sticky" to retain the values upon error checking so the user has the value they originally entered.

$result = mysql_query("SELECT * FROM facilities ORDER BY Street1 ASC") or 
$sticky= '';
if (isset($_POST['facility']))
$sticky = ($_POST['facility']);
$pulldown1 = '<select name="facility">';
$pulldown1 .= '<option></option>';
 while($row = mysql_fetch_array($result))
if($row['FacilitiesID'] == $sticky) {
$pulldown1 .= "<option selected value=\"{$row['FacilitiesID']}\">
} else {
$pulldown1 .= "<option value=\"{$row['FacilitiesID']}\">
$pulldown1 .= '</select>';
echo $pulldown1;    

Edited 3 Years Ago by happygeek: fixed formatting

This article has been dead for over six months. Start a new discussion instead.