1

我正在尝试从 Mysqli DB 中获取相关内容。通过 Like %% 很容易获取,但不会输出所需的相关内容。

我想有相关的帖子,类似于标题和内容。

结构:标题-文本和内容-长文本

这是代码:

<?php
$sql = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT *, MATCH(title, content) AGAINST('$CurrentPostTitle') AS score
FROM articles 
WHERE MATCH(title, content) AGAINST('$CurrentPostTitle') 
ORDER BY score DESC LIMIT 4");
while ($row = mysqli_fetch_array($sql)) {
$title = $row['title'];
echo $title;
echo "\r\n";
}
?>

但这不输出任何东西?

4

1 回答 1

1

启用Full Text标题并使用此代码:其伪代码

SELECT *, MATCH(title, body) AGAINST('$CurrentPostTitle') AS score
FROM articles 
WHERE MATCH(title, body) AGAINST('$CurrentPostTitle') 
ORDER BY score DESC LIMIT 5

我希望能帮助你

于 2017-07-29T08:00:32.517 回答