jatar_k

msg:3538182 | 10:56 pm on Dec 31, 2007 (gmt 0) |
what happens? do you get an error? I also assume this was a cut and paste error $keywords = explode(" ", $searchterm); you could also count spaces in the string, if there is a space then explode it, if not just carry on
|
brancook

msg:3538190 | 11:11 pm on Dec 31, 2007 (gmt 0) |
I don't get an error. Actually I typed that string out the wrong way when posting, I had "$keywords" in my code correctly. What actually happens is I keep getting the same 2 results from the database no matter what I type into the search box.
|
jatar_k

msg:3538191 | 11:12 pm on Dec 31, 2007 (gmt 0) |
have you tried echo'ing the query to see if it is getting constructed properly?
|
brancook

msg:3538208 | 11:33 pm on Dec 31, 2007 (gmt 0) |
When I insert this string: $keywords = explode(" ", $searchterm); and do a search with a phrase where I know that if the words were searched independently I would get results here is my echoed query: SELECT * FROM site_data WHERE description LIKE '%Array%' OR page_title LIKE '%Array%' OR keywords LIKE '%Array%' not sure where Array is coming from?
|
jatar_k

msg:3538239 | 1:53 am on Jan 1, 2008 (gmt 0) |
because $keywords is an array and you need to take each word out individually what are you wanting to do with the multiple words? make multiple searches? or do you want to use more ORs in your query?
|
brancook

msg:3538260 | 3:55 am on Jan 1, 2008 (gmt 0) |
What would be the difference between using more OR's and splitting the phrase into multiple searches?
|
jatar_k

msg:3538352 | 2:20 pm on Jan 1, 2008 (gmt 0) |
more ORs you would have to add each word to your query, maybe something like this $query = "SELECT * FROM site_data WHERE description LIKE '%" . $keywords[0] . "%' OR page_title LIKE '%" . $keywords[0] . "%' OR keywords LIKE '%" . $keywords[0] . "%' OR description LIKE '%" . $keywords[1] . "%' OR page_title LIKE '%" . $keywords[1] . "%' OR keywords LIKE '%" . $keywords[1] . "%'"; you would need to construct this in a loop so it added the right amount for the number of words entered multiple queries would be something like $query = "SELECT * FROM site_data WHERE description LIKE '%" . $keywords[0] . "%' OR page_title LIKE '%" . $keywords[0] . "%' OR keywords LIKE '%" . $keywords[0] . "%'"; then pull those results into an array then do $query = "SELECT * FROM site_data WHERE description LIKE '%" . $keywords[1] . "%' OR page_title LIKE '%" . $keywords[1] . "%' OR keywords LIKE '%" . $keywords[1] . "%'"; and pull those results you would again need to loop it to do a query for each word you might be best doing a query with both to start if that doesn't return enough results then split the phrase (if needed) and query for each word individually
|
brancook

msg:3538394 | 4:28 pm on Jan 1, 2008 (gmt 0) |
Thanks for the info I'll give it shoot.
|
|