PHP seach muiliple string For keywords

Status
Not open for further replies.

Ciarán Mc Cann

New Member
Well I have a MySQL database of over 1254 entrys and one the columns is address.And the address are all in the kildare area, so they all have kildare at the end of them. for example
22 Orchard Park The Curragh Co Kildare
I cant use this as it throws up almost the hole database
PHP:
// Retrieve all the data from the table
$result = mysql_query("SELECT * FROM PLANNING_APPLICATIONS WHERE DEVELOPMENT_LOCATION  LIKE '%$bylocation%'")
or die(mysql_error());}
The words that would be put into the seach would be the last thing before kildare in my example above it is "The Curragh". any idea's on what i could do?

Kind Regards
Ciaran Mc Cann
 

ph3n0m

New Member
try this instead

Code:
$result = mysql_query("SELECT * FROM PLANNING_APPLICATIONS WHERE DEVELOPMENT_LOCATION  LIKE '%$bylocation'")
 

Ciarán Mc Cann

New Member
nope still throws up almost the hole 1245 records, I was thinking maybe some sorta If() statment, after the query or somthing, there is no if like () fuction or anything like that ha is there?
 

ph3n0m

New Member
what exactly is the problem? what word(s) are you searching with? is $location the users input? or is it the word "kildare"?
 

Ciarán Mc Cann

New Member
$bylocation is the users input, which will be the word before Co.Kildare and basicly I want all the address that have the user input in this example "The Curragh" be outputted.

Basicly I think the problem is that the entrys are 2 long and have 2 much information in them for a SQL query to pick out the keywords the user inputs ($bylocation)
 

davidbehan

New Member
I don't understand the problem. If you were searching on "The Curragh", your sql search would only return those results with that in the string regardless of "Co Kildare" being at the end of every field record. Am I missing something???
 

Ciarán Mc Cann

New Member
oh maybe there is a problem with my code some where else, I will do a few checks, but I think I nearly have the problem fixed anyother way using the substr_count() fuction. ok I will check over my code. Thanks
 

Ciarán Mc Cann

New Member
ah got it, ha just a variable name wrong on an if statement. oh god I spent ages browsing around for a solution, ha ha. Thanks very much for your help.
 
Status
Not open for further replies.
Top