Jump to content

A little problem in my Search tool


npsari

Recommended Posts

Hello everyone reading this...

 

I will do my best to explain the problem i am facing

 

So, a user comes to my website and uses the search tool i created

 

Lets say he searches for "cheap telephone engineers in the town brighton"

 

Therefore, $key = "cheap telephone engineers in the town brighton";

 

I order to match his search, i use the following part...

 

<?php
$q = "SELECT * FROM ads WHERE ad_keywords LIKE '%{$key}%' ORDER BY RAND() ";
?>

 

The problem is that, It matches the exact term, i need something to match as more words as possible

 

Do you know how can i manage to do that

Link to comment
https://forums.phpfreaks.com/topic/139211-a-little-problem-in-my-search-tool/
Share on other sites

Thank you for the link

 

The thing is, this article still uses one word only

 

I need the query to match as much words possible from $key

 

hmm, I guess i will have to do it another way

 

I need to do a trick in php, use arrays maybe

Wait.  Is ad_keywords column a CSV with a bunch of keywords in it?  If it is, that's horrible database design and should most definitely be rewritten into another table with a one-to-many relationship with the ads table.

 

Yes, i have a colomn which is called: ad_keyword

 

I store the keywords there separated by spaces

 

Really, is that bad design

 

I can easily get data from it though, i just need to sort out the matching part

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.