Php 如何从具有数组的会话变量获取数据

Php 如何从具有数组的会话变量获取数据,php,arrays,session-variables,Php,Arrays,Session Variables,我有一个会话变量,其中存储了一个数组。现在,在另一个PHP页面中,我想逐行打印这些数组值。。。就像mysqli_fetch_数组函数的结果一样 $sql="SELECT complaints.c_id , user.first_name , user.last_name FROM ogc.complaints , ogc.user WHERE complaints.department='$deptname' and complaints.id=user.id and complaints.d

我有一个会话变量,其中存储了一个数组。现在,在另一个PHP页面中,我想逐行打印这些数组值。。。就像mysqli_fetch_数组函数的结果一样

$sql="SELECT complaints.c_id , user.first_name , user.last_name  FROM ogc.complaints , ogc.user WHERE complaints.department='$deptname' and complaints.id=user.id and complaints.district='$distr' " or die(mysql_error());
$result=mysqli_query($conn,$sql) ;
$count=mysqli_num_rows($result);
if(count>0)
{
    $row = array();
    $arr_row[]=array();
    while( $row = mysqli_fetch_array( $result ) )   
    {   
        $arr_row[]=$row;
        $_SESSION[ 'arrrows' ] = $arr_row;
        header("location:dists.php");
    }
}
在dists.php中

    session_start();
    $result=$_SESSION['arrrows'];
现在,我想使用这个$result通过不同行的列名访问数组的各个行和列,使用:


你能给你的问题添加一些代码吗?您可能需要研究序列化,但我不能完全确定。带有数组的会话变量是什么样子的?我将查询结果存储在一个页面和另一个页面的会话变量中,我想使用这个session变量来打印数据库值,比如particluar coumnsSide中的值注意:您可能需要添加一个
die
标题之后(“位置:dists.php”)行或代码,考虑到在该块之后有一些代码,仍将在重定向之前执行。不,在头之后没有代码,只有“if”循环结束。@Vyshnavi Samudrala。。。并移动
$\u会话['arrrows']=$arr\u行
while()
块之后的行。
foreach($_SESSION['array'] as $row) {
   echo $row;
}