无法在PHP中显示同一会话用户的所有数据

时间:2019-03-26 03:31:19

标签: php

问题是,当我启动一个会话并希望显示当前会话用户的所有数据时,是从数据库中仅获取一个数据。但是,当我将session_start和表放在一起时,我无法访问echo用户名。

<?php  
session_start();  
if(!isset($_SESSION["uname"]))
{
 header("location:userdash.php");

}else{

                include('db.php');
                $sql ="Select * from poolreservation where uname ='".$_SESSION['uname']."'";
                $re = mysqli_query($con,$sql);
                while($row=mysqli_fetch_array($re))
                {   
                    $id = $row['id'];
                    $resortname = $row['resortname'];
                    $hourstay = $row['hourstay'];
                    $addon = $row['add on'];
                    $cin = $row['cin'];

                }
}


?> 
<!DOCTYPE html>
<html lang="en">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Reservation History</title>
    <link rel="icon" type="text/css" href="image/icon/history.png">
</head>
<body>

      <div class="row">
        <div class="col-12">
          <div class="card text-center mt-2">
            <div class="card-header success-color mt-5">
              RESERVATION HISTORY
            </div>
            <div class="card-body">
              <div class="table-responsive">
                <table class="table table-striped table-bordered">
                  <thead>
                    <tr>
                      <th class="text-info">#</th>
                      <th class="text-warning">Name of resort</th>
                      <th class="text-warning">Hour of stay</th>
                      <th class="text-warning">Add-on</th>
                      <th class="text-warning">Date</th>
                    </tr>
                   </thead>
                   <tbody>
                        <th><?php echo $id; ?> </th>     
                        <th><?php echo $resortname; ?> </th>     
                        <th><?php echo $hourstay; ?> </th>
                        <th><?php echo $addon; ?> </th>     
                        <th><?php echo $cin; ?> </th>     
                   </tbody>
                </table>

我希望它显示他/她的所有数据,我正在处理交易历史记录。

0 个答案:

没有答案