Jump to content

How to Search a PHP Mysql Database


Don the dragon

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/153994-how-to-search-a-php-mysql-database/
Share on other sites

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.