sql 多关键字搜索
发布时间:2021-01-11 04:18:27 所属栏目:MySql教程 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 if(count($newstr)==1){//如果数组的元素个数为1个,则按单个条件进行查询 $sql = "select * from tb_info where title like '%".$newstr[0]."%' or c
|
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 if(count($newstr)==1){ //如果数组的元素个数为1个,则按单个条件进行查询
$sql = "select * from tb_info where title like '%".$newstr[0]."%' or content like '%".$newstr[0]."%'order by id desc ";
}else{
//合并查询结果集
for($i=0;$i<count($newstr);$i++){
$sql0.=" title like '%".trim($newstr[$i])."%'"." or";
}
for($j=0;$j<count($newstr);$j++){
$sql1.=" content like '%".trim($newstr[$j])."%'"." or";
}
$sql1=substr($sql1,-3); //去掉最后一个“or”
$sql="select * from tb_info where".$sql0.$sql1." order by id desc";
}
以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:ASP站长) 【免责声明】本站内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。 |
相关内容
未处理完善
-
无相关信息
最新更新


