JaMoUsE 0 Posted April 19, 2012 Share Posted April 19, 2012 (edited) One for the it boffins! cough Ant (help please!) Im creating an estate agents website as part of my uni course and it obviously needs a search feature. Im using HTML and have a small SQL database, Basically I have 5 or 6 locations and they work fine from the drop down menu, however i want an option that will return all locations. For example i have <select name = "city" id = "city"> <option value="Newcastle">Newcastle City Centre</option> <option value="Gosforth">Gosforth</option> <option value="Jesmond">Jesmond</option> <option value="Gateshead">Gateshead</option> <option value="Heaton">Heaton</option> <option value=" ">All Locations </option> </select> Is there a way you can select all the options? as no matter what i try i cant seem to get it to work? My SQL statement is this $type= $_REQUEST ["type"]; $city= $_REQUEST ["city"]; $nobedrooms= $_REQUEST ["nobedrooms"]; $price= $_REQUEST ["price"]; $typeselect=("SELECT * FROM property WHERE type LIKE'$type' AND city LIKE'$city' AND nobedrooms ='$nobedrooms'"); // execute sql statement $rstype = mysql_query($typeselect); // construct sql statement Thanks in advance Edited April 19, 2012 by JaMoUsE Link to comment Share on other sites More sharing options...
Ruler of Planet Houston 1 Posted April 19, 2012 Share Posted April 19, 2012 (edited) Like so... $type= $_REQUEST ["type"]; $city= $_REQUEST ["city"]; $nobedrooms= $_REQUEST ["nobedrooms"]; $price= $_REQUEST ["price"]; if($city == ' ' ){$where = " AND city LIKE '$city' ";}else{$where ='';} $typeselect=("SELECT * FROM property WHERE type LIKE'$type' $where AND nobedrooms ='$nobedrooms'"); Edited April 19, 2012 by Ruler of Planet Houston Link to comment Share on other sites More sharing options...
JaMoUsE 0 Posted April 19, 2012 Author Share Posted April 19, 2012 Thanks for the info lads ill check it out in a bit. Link to comment Share on other sites More sharing options...
JaMoUsE 0 Posted April 19, 2012 Author Share Posted April 19, 2012 (edited) Like so... $type= $_REQUEST ["type"]; $city= $_REQUEST ["city"]; $nobedrooms= $_REQUEST ["nobedrooms"]; $price= $_REQUEST ["price"]; if($city == ' ' ){$where = " AND city LIKE '$city' ";}else{$where ='';} $typeselect=("SELECT * FROM property WHERE type LIKE'$type' $where AND nobedrooms ='$nobedrooms'"); This code does return all locations but even if I select a specific location it still returns all locations Edited April 19, 2012 by JaMoUsE Link to comment Share on other sites More sharing options...
JaMoUsE 0 Posted April 19, 2012 Author Share Posted April 19, 2012 Cheers Ant appreciate you bringing your work home haha Link to comment Share on other sites More sharing options...
Ruler of Planet Houston 1 Posted April 22, 2012 Share Posted April 22, 2012 Ah bugger!!! I meant to put != instead of == Cheers Ant! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now