PHP-匹配搜索词mysql_query [英] PHP - Matching search terms mysql_query

查看:76
本文介绍了PHP-匹配搜索词mysql_query的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

im遇到一个php脚本问题,该php脚本从数据库检索值并查看与输入项匹配的值.我或者得到了resourceID#4错误或没有响应.

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!

推荐答案

是否已将字段索引为全文索引,并且是表myisam.有关更多详细信息,请参见.

Have you indexed the field as full text and is your table myisam. See this for more detail.

这篇关于PHP-匹配搜索词mysql_query的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆