array(0=>array('xm'=>'我是特别的'),1=>array('xm'=>'你好'), 2=>array('xm'=>'你好'), 3=>array('xm'=&"/> array(0=>array('xm'=>'我是特别的'),1=>array('xm'=>'你好'), 2=>array('xm'=>'你好'), 3=>array('xm'=&">
Home > Backend Development > PHP Tutorial > mysql多个关键字的查询解决思路

mysql多个关键字的查询解决思路

WBOY
Release: 2016-06-13 10:34:39
Original
1242 people have browsed it

mysql多个关键字的查询

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$list="";    $car = array('name'=>array(0=>array('xm'=>'我是特别的'),1=>array('xm'=>'你好'), 2=>array('xm'=>'你好'), 3=>array('xm'=>'你好')));    if(!$car['name']){        $list='Nothing';    }else{        $i = 1;        foreach($car['name'] as $nm)        {            if(strstr($list,$nm['xm']) && $i == 1)            {                $list = str_replace($nm['xm'],$nm['xm'].$i,$list);                $list .= $nm['xm'].($i+1).',';                $i++;            }else{                if(strstr($list,$nm['xm']))                {                    $list .= $nm['xm'].($i+1);                    $i++;                }else{                    $list .= $nm['xm'].',';                }            }        }    }
Copy after login


SQL code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$sql="SELECT * FROM table where table.title in ('$list') limit 0,10";
Copy after login

php输出:我是特别的,你好1,你好2,你好3
mysql查询语句应该怎样写可以使$list生效?或者其他相同效果的查询方法?
新手麻烦各位尽可能的写得详细一些,谢谢。






------解决方案--------------------
你有
$sql="SELECT * FROM table where table.title in ($list) limit 0,10";
我让你贴出
echo $sql;
的结果!拿到就那么难吗?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template