Jump to content

Need help: Mysql Where clause doesn't work for me


dlabacs

Recommended Posts

Hi guys,

 

I have my php/mysql SELECT code which doesn't return a result to what I have expected after execution of the code.

$sql="SELECT *FROM advert 
   WHERE ad_Type = '%{$service}%' AND
		ad_Street_No like '%{$location}%' OR
		ad_Street_Name like '%{$location}%' OR
		ad_Suburb like '%{$location}%' OR
		ad_Postcode like '%{$location}%' OR
		ad_State like '%{$location}%'";

 

The user will search on location and  the type of service available using parameters like street name,suburb, postcode and/or state in one textfield and then select a type of service from a dropdown menu. So for example  : "Select records from table 'advert' where type of service = 'e.g. hauling,digging,' located at e.g. Cardiff NSW". " something like that.

 

 

I have 2 records right now on my database :

1. Service: Hauling, Location: Cardiff NSW

2. Service: Digging , Location: Cardiff NSW

 

 

Now the problem is:

 

you search for "Hauling" service in "Cardiff" , will return 2 records (#1 and #2).

you search for "Digging" service in "Cardiff", will return 2 records (#1 and #2).

you search for either of the services in " Cardiff NSW", will return 0 results.

 

I got no idea on how to fix this. Please help me guys.  Thank you in advance.  :(  :(  :(

 

 

Best regards

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.