paulzhao2016
paulzhao2016
2018-01-10 04:52

用session传值,二维数组怎么只剩一维了?

5
  • 二维数组
  • session
        <?php 
  foreach ($res as  $value) {
  $sql2="select * from dadao_cart where userid='$userid' and goodid='$goodid'";
  $res2=mysqli_fetch_all(mysqli_query($conn,$sql2));
        $_SESSION['cart']=$res2;
  var_dump($_SESSION['cart']);
        }
  ?>

        <?php 
        require 'conn/conn.php';
        var_dump($_SESSION['cart']);
        ?>

第一页我把数据库的查询结果保存在session里,应该是一个二维的数组:array(1) { [0]=> array(4) { [0]=> string(1) "1" [1]=> string(1) "1" [2]=> string(1) "1" [3]=> string(1) "6" } } array(1) { [0]=> array(4) { [0]=> string(2) "27" [1]=> string(1) "2" [2]=> string(1) "1" [3]=> string(1) "4" } } array(1) { [0]=> array(4) { [0]=> string(2) "31" [1]=> string(1) "3" [2]=> string(1) "1" [3]=> string(1) "1" } } array(1) { [0]=> array(4) { [0]=> string(2) "30" [1]=> string(1) "4" [2]=> string(1) "1" [3]=> string(1) "7" } },但到了第二页却只显示最后一项

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

6条回答