spearchilduser Posted January 11, 2012 Share Posted January 11, 2012 Hi im just querying im tryign to do a simple search on my database and set it so it searches between two price values from a drop down box html> <body> <form action="bedroomsearch.php" method="POST" > Price: <select name="Price"> <option> 100-300</option> <option> 200-500</option> <option> 400-700</option> <option> 600-900</option> <option> 900+ </option> </select> </br></br> </br></br> <p><input type="submit" value="Send Details" name="TypeSubmit"></p> </form> $query = "SELECT * FROM properties WHERE Price ='".$_POST['Price']."'"; $result = mysql_query($query); That is the query id use to search for the prices how do i do it so i can search for all the entries between the two values in the drop box? Link to comment https://forums.phpfreaks.com/topic/254796-search/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 11, 2012 Share Posted January 11, 2012 http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html#operator_between Link to comment https://forums.phpfreaks.com/topic/254796-search/#findComment-1306461 Share on other sites More sharing options...
spearchilduser Posted January 11, 2012 Author Share Posted January 11, 2012 Im sorry im new to php im not sure how i woudl lay it out is there anywhere where i could get the layout for the expression at all ? and also if i wanted to be able to do say 3 things to search on would that all go into one query ? and if so in my while statement to gather the information for the results what would i need to put into it so it expects more than one criteria while ($row = mysql_fetch_array($result)) so after the $result Link to comment https://forums.phpfreaks.com/topic/254796-search/#findComment-1306463 Share on other sites More sharing options...
litebearer Posted January 11, 2012 Share Posted January 11, 2012 Perhaps something like... single SELECT * FROM table WHERE field BETWEEN $low AND $high double SELECT * FROM table WHERE (field BETWEEN $low AND $high) OR (field BETWEEN $low1 AND $high2) Link to comment https://forums.phpfreaks.com/topic/254796-search/#findComment-1306486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.