用一串数据"1,2,3,13,14,18,30,40,90,....."来昨条件pId=1;pId=13这样来查的相关记录

解决方案 »

  1.   

    $str="1,2,3,13,14,18,30,40,90";
    arr_str=explode(",",$str);
    foreach($arr_str as $Val)
    { $condition.=" or pid='".$Val."'";}
    if($condition)
    {
    $condition = "where  ".substr($condition,3,strlen($condition)-3);$sql = "select * from table ". $condition ." order by pid asc";
      

  2.   

    $str="1,2,3,13,14,18,30,40,90";
    arr_str=explode(",",$str);
    foreach($arr_str as $Val)
    { $condition.=" or pid='".$Val."'";}
    if($condition)
    {
    $condition = "where  (".str($condition,3,strlen($condition)-3).") ";}
    $sql = "select * from table ". $condition ." order by pid asc";如果说还有其它的条件的话,
    $condition = " where  (".str($condition,3,strlen($condition)-3).") ";
    改成;
    $condition = " and (".str($condition,3,strlen($condition)-3).") ";$sql = "select * from table where field ='sadgsag' ". $condition ." order by pid asc";
      

  3.   

    $str='1,2,13,25,458';
    if(!empty($str)){
       $sql=" select * from table where id in ( $str ) ";
    }...
    后面用mysql_query 查即可。