首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

PHP 怎么轮循

2012-03-26 
PHP 如何轮循我是想求能满足多少个订单?为什么我这样不行??$order_id mysql_query(select order_id fro

PHP 如何轮循
我是想求能满足多少个订单?为什么我这样不行??

$order_id = mysql_query("select order_id from myr_order where '".strtotime('-'.$date.' day')."' <= add_time and add_time <= '".mktime()."'");
while($t_id = mysql_fetch_array($order_id,MYSQL_ASSOC)){
$is_in =1;
$num = 0;
$que = mysql_query("select goods_sn,order_id from myr_order_goods where order_id = '".$t_id['order_id']."'");
while($gs = mysql_fetch_object($que)){
if(in_array($gs->goods_sn,$sn) && $is_in==1){
$is_in = 1;
}elseif(in_array($gs->goods_sn,$sn) && $is_in==0){
$is_in = 0;
break;
}
}
if($is_in == 1){
$num = $num + 1;
}elseif($is_in == 0){
continue;
}
}
  echo $num;

[解决办法]

PHP code
$sql = "select order_id from myr_order where '".strtotime('-'.$date.' day')."' <= add_time and add_time <= '".mktime()."'";$order_id = mysql_query($sql);$num = 0;// 放到外面来试一试while($t_id = mysql_fetch_array($order_id,MYSQL_ASSOC)){    $is_in =1;    $que = mysql_query("select goods_sn,order_id from myr_order_goods where order_id = '".$t_id['order_id']."'");    $gs = mysql_fetch_object($que);    if(in_array($gs->goods_sn,$sn) && $is_in){        $is_in = 1;    }elseif(in_array($gs->goods_sn,$sn) && !$is_in){        $is_in = 0;        break;    }    if($is_in){        $num = $num + 1;    }elseif(!$is_i){        continue;    }}  echo $num; 

热点排行