UnknownPlayer Posted January 25, 2011 Share Posted January 25, 2011 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? Link to comment https://forums.phpfreaks.com/topic/225663-php-mysql-hrlp-for-search-form/ Share on other sites More sharing options...
AbraCadaver Posted January 25, 2011 Share Posted January 25, 2011 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"? Link to comment https://forums.phpfreaks.com/topic/225663-php-mysql-hrlp-for-search-form/#findComment-1165158 Share on other sites More sharing options...
UnknownPlayer Posted January 25, 2011 Author Share Posted January 25, 2011 Something like "dota" then "allstars" I just need to know how other search engines work :S Link to comment https://forums.phpfreaks.com/topic/225663-php-mysql-hrlp-for-search-form/#findComment-1165160 Share on other sites More sharing options...
AbraCadaver Posted January 25, 2011 Share Posted January 25, 2011 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 Link to comment https://forums.phpfreaks.com/topic/225663-php-mysql-hrlp-for-search-form/#findComment-1165164 Share on other sites More sharing options...
UnknownPlayer Posted January 25, 2011 Author Share Posted January 25, 2011 Can u give me example of full-text searching please ? Link to comment https://forums.phpfreaks.com/topic/225663-php-mysql-hrlp-for-search-form/#findComment-1165166 Share on other sites More sharing options...
AbraCadaver Posted January 25, 2011 Share Posted January 25, 2011 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') Link to comment https://forums.phpfreaks.com/topic/225663-php-mysql-hrlp-for-search-form/#findComment-1165177 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.