Hi,
I am working on a search page which has the following selection boxes;
Location
Property type
Number of bedrooms
Price
I have never done a search query using multiple selection boxes.
Please help!
Help - Database results from selections
Moderator: General Moderators
- mhouldridge
- Forum Contributor
- Posts: 267
- Joined: Wed Jan 26, 2005 5:13 am
For each drop down determine if the pulldown not empty. If it isn't empty make a where statement out of the data.
Do something similar for each pull down. Then make the query.
Execute it and your done.
Hope that helps.
If you have multiple tables you'll have to calculate first if joins are necessary and so forth.
Code: Select all
if (!empty($_POST['location')){
$location = "location = ".$_POST['location']; //make sure you sanitize the data first
} else {
$location = ""; //It's empty no qualifier.
}Code: Select all
$sql = "SELECT * FROM sometable WHERE ".$location." ".$someother;Hope that helps.
If you have multiple tables you'll have to calculate first if joins are necessary and so forth.