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
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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.