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