Page 1 of 1

Dropdown list to query database and show results

Posted: Thu May 13, 2010 6:42 am
by tom8521
How can I use a dropdown list to query a database and return the results. This only needs to be simple by the way, nothing too advanced.

The information in the dropdown list should be named 'Prop_type' and will be getting information from the 'property' table. If someone knows how to do this, please help me. I don't think it is overly techy for all you brainiacs.

Thanks in advance! :D
Tom.

Re: Dropdown list to query database and show results

Posted: Thu May 13, 2010 7:39 am
by roders
query the database as you would normally do.
Create your dropdown as you would normal create, then your <option> tags should be included inside the while loop of the query e.g.

Code: Select all

$query="select * from table";
$result=mysql_quer($result);
while($row=mysql_fetch_array($result))
{
    echo "<option value=\"".$row['fieldnamevalue']."\">".$row['fieldnamedescription']."</option>";
}

Re: Dropdown list to query database and show results

Posted: Thu May 13, 2010 1:48 pm
by tom8521
I still don't understand this.

I use a form to post these details:

Prop_beds
Prop_type
Prop_location

I need each to be checked alongside the 'property' table within the database. Help?