Jump to content

php & mysql hrlp for search form


UnknownPlayer

Recommended Posts

I need help with search form.

When someone enter in search form "dota allstars", if in mysql is no such a thing like that at table "news", i wonna to find similar data, how can i do that?

 

What do you consider "similar data"?

Something like "dota" then "allstars"

I just need to know how other search engines work :S

 

You can use LIKE and the wildcard % or better would be full-text searching: http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html

Can u give me example of full-text searching please ?

 

Look at the link I posted.  There are examples all in there.  You have to set the fields as FULLTEXT in the table definition:

 

CREATE TABLE articles (
    ->   id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
    ->   title VARCHAR(200),
    ->   body TEXT,
    ->   FULLTEXT (title,body)
    -> ) ENGINE=MyISAM;

 

Then something like:

 

 SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('dota allstars')

 

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.