一般来说,关键字是在 MySQL 字段中搜索的,例如;
[tbl_hp] 标识,标题
1, Harry Potter and the Philosopher's Stone
2, Harry Potter and the Chamber of Secrets
3, Harry Potter and the Prisoner of Azkaban
4, Harry Potter and the Goblet of Fire
5, Harry Potter and the Order of the Phoenix
6, Harry Potter and the Half-Blood Prince
7, Harry Potter and the Deathly Hallows
PHP
$keyword = "Philosopher";
$keyword = "Harry Potter";
SQL
SELECT `id` FROM `tbl_hp` WHERE `title` LIKE '%" . $keyword . "%';
然后结果是;
"Philosopher" => 1
"Harry Potter" => 1,2,3,4,5,6,7
但是如何做到这一点?
[tbl_hp_keywords] id,关键字
1, philosopher
2, chamber
3, azkaban
4, goblet
5, phoenix
6, prince
7, hallows
8, prisoner
9, Prisoner of Azkaban
10, Half-Blood Prince
PHP
$keyword = "Harry Potter and the Chamber of Secrets";
$keyword = "Harry Potter and the Prisoner of Azkaban";
$keyword = "Harry Potter and the Half-Blood Prince";
然后结果是;
"Harry Potter and the Chamber of Secrets" => 2
"Harry Potter and the Prisoner of Azkaban" => 3,8,9 => or even better result is 9
"Harry Potter and the Half-Blood Prince" => 6,10 => or even better resurt is 10
关于如何做到这一点的任何帮助或想法......在此先感谢:)