PHP - 匹配搜索词 mysql_query
我遇到了一个 php 脚本问题,该脚本从数据库中检索值并查看哪些值与输入项匹配。我要么收到资源 ID #4 错误,要么没有响应。
我基本上试图检索相似的条目,并且这些相似的条目显示其提交的名称和日期,
$input = mysql_real_escape_string($_POST["interest"]);
$query1 = "SELECT name,interest_desc,date, MATCH(interest_desc) AGAINST('$input') AS score
FROM interests
WHERE MATCH(interest_desc) AGAINST('$input')
ORDER BY score DESC
LIMIT 10
";
$result = mysql_query($query1) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
echo $row['name'];
echo $row['interest_desc'];
echo $row['date'];
}
我的语法一定出了问题,有什么指示吗?我为此抓狂!
im having issue with a php script that retrieves values from a database and see's which ones match an input term. I either get the resourceID #4 error or no response.
Im basically trying to retrieve similar entries and of those similar entries show the name and date of their submission
$input = mysql_real_escape_string($_POST["interest"]);
$query1 = "SELECT name,interest_desc,date, MATCH(interest_desc) AGAINST('$input') AS score
FROM interests
WHERE MATCH(interest_desc) AGAINST('$input')
ORDER BY score DESC
LIMIT 10
";
$result = mysql_query($query1) or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
echo $row['name'];
echo $row['interest_desc'];
echo $row['date'];
}
I must be going wrong with my syntax, any pointers? im pulling my hair out over this!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否将该字段索引为全文,并且是您的表 myisam。有关更多详细信息,请参阅此。
Have you indexed the field as full text and is your table myisam. See this for more detail.