foreach循环不会从$返回值

我已经设置了一个$ _SESSION变量,并且看不出为什么我的foreach循环不起作用。 如果我回显var $ v,我会得到的只是一个白色屏幕。 如果我回显我的会话var,那么我可以看到正在传递的数据格式为wd10,wd11,wd12。

如果有人能检查我的循环并指出我的错误,我将不胜感激。 谢谢

我在页面顶部有session_start(),所有会话和mysql查询都正常工作。

<?php
    foreach ($_SESSION['boxdest2'] as $key=>$value)
        {   
      $temp = explode(",", $value);
      foreach($temp as $k => $v )
      {
        $query = "SELECT * FROM boxes WHERE customer = '$_SESSION[kt_idcode_usr]' AND status = 1 AND custref = '$v'";
        $result = mysql_query($query) or die(mysql_error());
        $row = mysql_fetch_array($result) or die(mysql_error());
        $rack = $row['rack'] . "-" . $row['column'] . "-" . $row['row'] .  "-" . "(" . $row['bay'] . ")";

    //    $query = "UPDATE boxes SET status = '9' WHERE customer = '$customer' AND department = '$dept' AND custref = '$v'";
    //    mysql_query($query) or die('Error, query failed');
    //  
        $query = 'INSERT INTO `act` (`slot`, `service`, `activity`, `department`, `company`, `address`, `user`, `item`, `destroyedby`, `destroyedby_date`, `date`, `new`) VALUES (''.$rack.'', ''.$service.'', ''.$activitys.'', ''.$dept.'', ''.$company.'', ''.$address.'', ''.$user.'', ''.$v.'', ''.$user.'',NOW(),NOW(), ''.$new.'');';
       mysql_query($query) or die('Error, query failed');
        }
        }
?>
链接地址: http://www.djcxy.com/p/59739.html

上一篇: foreach loop not returning values from $

下一篇: Distinct values from while loop