Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.