我的 MySQL 数据库表包含 2510 条记录。当我尝试使用全文搜索在列中搜索字符串时,有时我没有得到任何结果。只是一个空的 html 表。
例如,我正在搜索作者“Peter Schmidt”。如果我搜索“Peter”,我会找到正确的作者,但如果我搜索“Schmidt”,html 表会显示其他作者,但不是正确的作者。作者的栏目由“姓、名”(施密特、彼得)组成。
这是我的一段代码:
$author = mysql_real_escape_string($_GET['author']);
$sql = "SELECT * FROM books WHERE MATCH(author) AGAINST ('$author' IN BOOLEAN MODE)";
$query = mysql_query($sql);
if (!$query) {
echo 'We cannot find the author you are searching for. Please try again.';
echo '<a href="'.$_SERVER['PHP_SELF'].'" class="back" style="margin:0;" title="Go back">» Go back</a>';
} else {
echo '<p>These authors match your query:</p><table>'
while ($result = mysql_fetch_array($query)) {
echo '<tr><td>'.$result['author'].'</td></tr>';
}
echo '</table>'
}
是什么导致了这个问题?