Hi,

I am in the process of creating a Real estate web site and it needs to have a search able database. I am trying to have someone select an option from a menu, then hit search and restrict the results based on the URL variables. I know how to use $GET [id] and I have been trying the same for the search options, with no luck as of yet.

My recordset:

$query_rs_listings = "SELECT listings.Id, listings.town, listings.mkt_area, listings.list_price, listings.address, listings.ml, listings.list_office, listings.list_office_phone, listings.property_type, listings.baths, listings.bedrooms, listings.square_feet, listings.acreage FROM listings WHERE listings.property_type= $_GET[property_type]";

What am I doing wrong?? I always receive an error message after I hit submit on the search page:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 10' at line 1

so I know its something wrong in the recordset. If anyone has encountered this or can help, it would be greatly appreciated.

Try replacing it with the following:

$query_rs_listings = "SELECT `listings.Id`, `listings.town`, `listings.mkt_area`, `listings.list_price`, `listings.address`, `listings.ml`, `listings.list_office`, `listings.list_office_phone`, `listings.property_type`, `listings.baths`, `listings.bedrooms`, `listings.square_feet`, `listings.acreage` FROM `listings` WHERE `listings.property_type`='".$_GET[property_type]."'";

The 2 things I did to the script was I added the appropriate types of quotations marks around each piece of text and I made sure the $_GET array wasn't inside the string.

I am still receiving an error:

Unknown column 'listings.Id' in 'field list'

Id is definitely a column in the table. What could possibly be wrong with the query??

Id is definitely a column in the table.

If all your columns are not starting with listings. (in the field name like you have mentioned in the quote) and if you have the appropriate version of mysql then your code should look like the following:

$query_rs_listings = "SELECT `Id`, `town`, `mkt_area`, `list_price`, `address`, `ml`, `list_office`, `list_office_phone`, `property_type`, `baths`, `bedrooms`, `square_feet`, `acreage` FROM `listings` WHERE `property_type`='".$_GET[property_type]."'";

Also if you are selecting all columns then you can use the following:

$query_rs_listings = "SELECT * FROM `listings` WHERE `property_type`='".$_GET[property_type]."'";

Thanks for your help so far, I'm getting closer. Now its restricting the results, but not displaying the property types I selected. It just doesn't select anything. Any thoughts?

Here is the recordset for the search page:

$query_rs_search = "SELECT `town`, `list_price`, `address`, `ml`, `property_type`, `baths`, `bedrooms` FROM `listings` ";

Recordset from list (results) page:

$query_rs_listings = "SELECT `Id`, `town`, `mkt_area`, `list_price`, `address`, `ml`, `list_office`, `list_office_phone`, `property_type`, `baths`, `bedrooms`, `square_feet`, `acreage` FROM `listings` WHERE `property_type`='".$_GET[property_type]."'";

Does anyone know where to go from here?? Every time I run the search it doesn't return any results from the database.

u can use zoom search for the same.
Good tool

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.