怎么回事,你是不是在asp中写sql语句啊rs.open "select * from news where title like'%" &title&"'% and id !=" &id& "order by time desc limit 0,5",conn,1,1
没有,我没有加(""),我的意思其实是 $result=mysql_query("select * from news where title like '%$title%' and id!='$id' order by time DESC limit 0,5"); 的意思,这里是没错的,好像是like '%$title%'的问题
你应该取$title 中的关键字搜索,如果用 title like '%$title%' 可能找不到。
你应该取$title 中的关键字搜索,如果用 title like '%$title%' 可能找不到对呀,我也是这么想的,可是我就是不知道怎么取出关键字,能指点一下吗
例如:例如你想搜索“瑞星免费下载”,你就可以输入:“瑞星 免费 下载”,然后用 $search='瑞星 免费 下载'; $arry_ls=explode(' ',$search); 然后用循环把$array_ls数组中的元素组成一个条件表达式,如下格式: $ls=' and (title like '%瑞星%' or title like '%免费%' or title like '%下载%'); $sql="select * from news where id!='$id'".$ls." order by time DESC limit 0,5";这样不就可以了吗?
变量要从字符串中分离才清楚:sql="select * from news where title like '%" .$title. "%' and id!='" .$id. "' order by time DESC limit 0,5"; 用"."连接字符串。以前我也经常碰到这个问题的,不行的话就连接一下变量,注意格式就好了。
desc limit 0,5",conn,1,1
$result=mysql_query("select * from news where title like '%$title%' and id!='$id' order by time DESC limit 0,5");
的意思,这里是没错的,好像是like '%$title%'的问题
我明白你说的意思,可是我又没办法判断每条信息的标题哪几个个字可以组成关键词,拆分也不知道该怎么拆
1.预定关键字,匹配title是否含有关键字,再进行查询
2.在每条记录中加入关键字字段,查询关键字相同记录
你试试这个:like binary,不过它会对大小写敏感
你试试这个:like binary,不过它会对大小写敏感
$search='瑞星 免费 下载';
$arry_ls=explode(' ',$search);
然后用循环把$array_ls数组中的元素组成一个条件表达式,如下格式:
$ls=' and (title like '%瑞星%' or title like '%免费%' or title like '%下载%');
$sql="select * from news where id!='$id'".$ls." order by time DESC limit 0,5";这样不就可以了吗?
用"."连接字符串。以前我也经常碰到这个问题的,不行的话就连接一下变量,注意格式就好了。
我没办法把标题中的单词给分隔开啊
“瑞星免费下载”这是标题,我要怎么把它拆成“瑞星 免费 下载”