Jump to content

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

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.