Hi, I need some help creating a good search tool using only php and MySQL. I actually use a VERY simple query to search the DB, but this is not good enough.
$query = “SELECT * FROM tuts WHERE description LIKE ‘%$search%’”;
I really need to make this better. Any tutorial o help will be much appreciated.
Thanks
Burhan
07-11-2004, 02:35 AM
See http://dev.mysql.com/doc/mysql/en/Fulltext_Search.html
SalehJamal
07-11-2004, 10:15 AM
and http://www.zend.com/zend/tut/tutorial-ferrara1.php
Thanks a lot, this has been of great help.
Fulltextsearch in mysql is very nice. I use it in several projects, but still give the option for a standard 'word' search.
Newer version of mysql support Boolean searches. This query assume that it does not.
Read the articled linked in the aaboe posts. And be sure to created your fulltext index.
// Relevence query
$sql = "SELECT search.id AS id, search.title AS title, search.content AS content, search.keywords AS keywords,
search.content_type AS content_type, search.is_series AS is_series, seriesmatch.title AS serieslink,
MATCH ( search.title, search.content, search.keywords )
AGAINST ( '$query' ) AS score
FROM uxnx_content AS search
LEFT JOIN uxnx_content AS seriesmatch ON ( search.series = seriesmatch.id )
WHERE search.searchable = 1 AND MATCH ( search.title, search.content, search.keywords )
AGAINST ( '$query' ) AND search.content != ''";