Jump to content

creating a better search for a facility


dazz_club

Recommended Posts

Hi guys,

 

Ive come to the point of adding a search facility for my project. I've got one, but i think its a but loose. What i mean by this, if i type in dog, it will pull out everything that has d,o,g.

 

would it be better to use match instead of like?

 

if anyone has read useful search tutorials that they could post a link to, i would be most grateful.

 

kind regards

Darren

Link to comment
https://forums.phpfreaks.com/topic/102146-creating-a-better-search-for-a-facility/
Share on other sites

it depends on what you're using for your search? what does your code look like now?

 

usually, my searches are pulling stuff out of a database, so I just do something like:

 

$search_for = "dog";

 

$query = "SELECT * FROM table WHERE some_column LIKE '%$search_for%' ";

 

this will return anything that say's "Dog" or "Doggie" or "hotdog" etc...

well here is the existing coding i am using;

$query = "SELECT * FROM  contacts WHERE first_name LIKE \"%$search%\" OR surname LIKE  \"%$search%\" OR company_name LIKE  \"%$search%\" OR position LIKE \"%$search%\" ORDER BY id  DESC" . " LIMIT $offset, $rowsPerPage" ;

 

i searching a table thats full of members, their name, where they live, you know the boring stuff. Well if i do type in dog in my search term in theory it shouldnt return anything, should it? As i have no members called dogs at all.

 

kind regards

Darren

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.