php高手帮下忙,explode 多个分割的问题

$items=”49|48″;//49|48|45|61……
$tmp = explode(“|”, $items);
$coun = count($tmp);
for( $i=0;$i < $coun; $i++){ $obj_db->simplequery(“update member set yz=’1′ where );
}

上面代码执行是正确的,达到了以下效果:

$obj_db->simplequery(“update member set yz=’1′ where );

$obj_db->simplequery(“update member set yz=’1′ where );

……

现在$items数组变成了这样:

$items=”49,3|48,2″;//49,3|48,2|45,6|61,3……

执行如下:

$items=”49,3|48,2”;
$tmp = explode(“|”, $items);
$coun = count($tmp);
for( $i=0;$i < $coun; $i++){ $tmp2 = explode(",", $tmp[$i]); $obj_db->simplequery(“update member set yz=’1′ where );
}

这段代码执行后效果如下:

$obj_db->simplequery(“update member set yz=’1′ where );

只执行了数组$tmp2[0]最后一个=48值,

如何能让它执行所有呢?即:

$obj_db->simplequery(“update member set yz=’1′ where );

$obj_db->simplequery(“update member set yz=’1′ where );

……

谢谢!

回复讨论(解决方案)

$items=”49,3|48,2″;
$tmp = explode(“|”, $items);
$coun = count($tmp);
for( $i=0;$i < $coun; $i++){ $tmp2 = explode(",", $tmp[$i]); //$obj_db->simplequery(“update member set yz=’1′ where );
echo “update member set yz=’1′ where , php_eol;
}

update member set yz=’1′ where id=49
update member set yz=’1′ where id=48

没有问题

$items=”49,3|48,2″;
$tmp = explode(“|”, $items);
$coun = count($tmp);
for( $i=0;$i < $coun; $i++){ $tmp2 = explode(",", $tmp[$i]); //$obj_db->simplequery(“update member set yz=’1′ where );
echo “update member set yz=’1′ where , php_eol;
}

update member set yz=’1′ where id=49
update member set yz=’1′ where id=48

没有问题

谢谢!表达错了,主要问题如下:

for( $i=0;$i < $coun; $i++){ $tmp2 = explode(",", $tmp[$i]); $query="select * from member where ; $result=$obj_db->simplequery($query);
$num=$obj_db->numrows($result);
}

执行后$num怎么是1啊?明明是2条符合要求的,如何才能等于2

谢谢!

Posted in 未分类

发表评论