Don the dragon Posted April 14, 2009 Share Posted April 14, 2009 Hi Please can someone help me with a query on a property website that i am developing. I have a drop-down list of areas in which people can select which area they would like to search, then i have a 'price from' to a 'price to' and then another drop down list in which people can choose from a list of options such as if it is a waterfront property, north facing etc. What i would like to know is how to make them all work together and particulary how to do the 'price from' to 'price to' function and how to make it search the db and bring up the results. Thanks Donovan Quote Link to comment https://forums.phpfreaks.com/topic/153994-how-to-search-a-php-mysql-database/ Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 do you have any code in the moment? Quote Link to comment https://forums.phpfreaks.com/topic/153994-how-to-search-a-php-mysql-database/#findComment-809417 Share on other sites More sharing options...
defeated Posted April 14, 2009 Share Posted April 14, 2009 $query=mysql_query("SELECT * FROM yourtable WHERE areafield='$areaselected' AND pricefield>'$lowerlimit' AND pricefield<'$upperlimit' AND propertytypefield='$propertytype' ORDER BY pricefield") or die("Uh oh, Something went wrong with the query: ".mysql_error()); That should do the trick. $areafield is the name of your select for area $lowerlimit is the name of your select for lower price limit $upperlimit is the name of your select for upper price limit $propertytype is the name of your select for waterfront etc. ORDER By will order results by the price Quote Link to comment https://forums.phpfreaks.com/topic/153994-how-to-search-a-php-mysql-database/#findComment-809502 Share on other sites More sharing options...
Don the dragon Posted April 15, 2009 Author Share Posted April 15, 2009 Oh great. Ill give it a go right now. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/153994-how-to-search-a-php-mysql-database/#findComment-810416 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.