PHP - Matching search terms mysql_query

不打扰是莪最后的温柔 提交于 2019-12-25 07:49:54

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/8497951/php-matching-search-terms-mysql-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!