douyi1855 2016-05-24 06:48
浏览 54
已采纳

PHP显示基于student_name的数据,但不基于student_username

I have a difficulty to display an item of a student based on the student_name. Previously I was able to display an item based on student_username but not using student_name. but now I want to use student_name to display the item which from student_name. I attached together with my code part.

<div class="row">
    <!-- Welcome -->
    <div class="col-lg-12">
        <div class="alert alert-info">
            <?php
            include("connection.php");
            $username=$_SESSION['username'];
            $sql=mysql_query("SELECT student_name FROM register WHERE student_username='$username'");
            $ee=mysql_fetch_array($sql);
            ?>
            <i class="fa fa-folder-open"></i><b>&nbsp;Hello ! </b>Welcome Back <b><?php echo $ee['student_name']; ?> </b>
        </div>
    </div>
    <!--end  Welcome -->
</div>

<div class="row">
            <div class="col-lg-12">
                   <div class="table table-responsive">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                           <th>S.no</th>
                           <th>Parcel Number</th>
                           <th>Date Recieved</th>
                           <th>Date of Collected</th>
                           <th>Recieved Time</th>
                           <th>Collect Time</th>
                           <th>Status</th>
                           <th>Sent By</th>
                            <th>Sent To</th>
                        </tr>
                        </thead>

                     <?php
        include("connection.php");
        $sql1=mysql_query("SELECT * FROM add_parcel WHERE send_to='$username'");
        $i=1;
        while($row=mysql_fetch_array($sql1)){
            echo '<tr class="record"><td>'.$i++.'</td><td>'.$row['date_recieve'].'</td><td>'.$row['date_collect'].'</td><td>'.$row['recieve_time'].'</td><td>'.$row['collect_time'].'</td><td>'.$row['status'].'</td><td>'.$row['sender_name'].'</td><td>'.$row['send_to'].'</td></tr>';
        }
?>

Student Dashboard Admin panel add item

add_parcel table = parcel_id,parcel_num,date_recieve,date_collect,recieve_time,collect_time,status,sender_name,send_to

register table = student_id,student_username,student_name,student_address,student_age,student_icenumber, student_email,student_phone,password
  • 写回答

1条回答 默认 最新

  • duan0714 2016-05-24 07:04
    关注

    Try this code instead:

    <div class="row">
        <!-- Welcome -->
        <div class="col-lg-12">
            <div class="alert alert-info">
                <?php
                    include("connection.php");
                    $username=$_SESSION['username'];
                    $student_name=$_SESSION['student_name'];
                    $sql=mysql_query("SELECT student_name FROM register WHERE student_name='$student_name'");
                    $ee=mysql_fetch_array($sql);
                ?>
                <i class="fa fa-folder-open"></i><b>&nbsp;Hello ! </b>Welcome Back <b><?php echo $ee['student_name']; ?> </b>
            </div>
        </div>
        <!--end  Welcome -->
    </div>
    
    <div class="row">
        <div class="col-lg-12">
             <div class="table table-responsive">
                 <table class="table table-hover">
                     <thead>
                         <tr>
                             <th>S.no</th>
                             <th>Parcel Number</th>
                             <th>Date Recieved</th>
                             <th>Date of Collected</th>
                             <th>Recieved Time</th>
                             <th>Collect Time</th>
                             <th>Status</th>
                             <th>Sent By</th>
                             <th>Sent To</th>
                         </tr>
                     </thead>
    
                     <?php
                         include("connection.php");
                         $sql1=mysql_query("SELECT * FROM add_parcel WHERE send_to='$student_name'");
                         $i=1;
                         while($row=mysql_fetch_array($sql1)){
                             echo '<tr class="record"><td>'.$i++.'</td><td>'.$row['date_recieve'].'</td><td>'.$row['date_collect'].'</td><td>'.$row['recieve_time'].'</td><td>'.$row['collect_time'].'</td><td>'.$row['status'].'</td><td>'.$row['sender_name'].'</td><td>'.$row['send_to'].'</td></tr>';
                         }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法