doulangchao8934 2017-03-14 21:39
浏览 46
已采纳

在php中从表中显示多个列表项

I do the flowing code I want to show all applied jobs in a list but in my code it show only the first job >>>Please If any one know help me....

<?php
        include("includes/db.php");

            //////////////////////////////////////////////////////////////
//get jobseeker personal information
            //$user=$_SESSION['Email'];          
             $get_jobseeker="select * from jobseeker where Email='$user'";           
             $run_jobseeker=mysqli_query($con, $get_jobseeker);          
             $row_jobseeker=mysqli_fetch_array($run_jobseeker);          
             $ID=$row_jobseeker['ID'];                   
//get jobseeker aplication          
              $get_app="select * from job_application where Jobseeker_ID='$ID'";             
             $run_app=mysqli_query($con, $get_app);          
             $row_app=mysqli_fetch_array($run_app);          
             $Job_entity_id=$row_app['Job_entity_id'];
//get jobseeker job_entity           
        $get_job="select * from job_entity where id='$Job_entity_id'";
        $run_job=mysqli_query($con, $get_job);
        $i=0;
        while($row_job=mysqli_fetch_array($run_job)){
            $id=$row_job['id'];
            $Title=$row_job['Title'];
            $i++;


      ?>
    <div class="list-group">
    <a class="list-group-item" href="my_account.php?job=<?php echo $id; ?>"><span><?php echo $Title; ?></span></a>
    <?php } ?>
    </div>  
  • 写回答

1条回答 默认 最新

  • doulan9287 2017-03-14 21:56
    关注

    Does one job_application has more job_entities, or one job_seeker has more job_applications?

    I think proper code should be:

    <div class="list-group">
    <?php
            include("includes/db.php");
    
                //////////////////////////////////////////////////////////////
    //get jobseeker personal information
                //$user=$_SESSION['Email'];          
                 $get_jobseeker="select * from jobseeker where Email='$user'";           
                 $run_jobseeker=mysqli_query($con, $get_jobseeker);          
                 $row_jobseeker=mysqli_fetch_array($run_jobseeker);          
                 $ID=$row_jobseeker['ID'];                   
    //get jobseeker aplication          
                  $get_app="select * from job_application where Jobseeker_ID='$ID'";             
                 $run_app=mysqli_query($con, $get_app);          
                 $i = 0;
                 while ($row_app=mysqli_fetch_array($run_app)) {          
                     $Job_entity_id=$row_app['Job_entity_id'];
                     //get jobseeker job_entity           
                     $get_job="select * from job_entity where id='$Job_entity_id'";
                     $run_job=mysqli_query($con, $get_job);
                     while($row_job=mysqli_fetch_array($run_job)){
                        $id=$row_job['id'];
                        $Title=$row_job['Title'];    
          ?>
        <a class="list-group-item" href="my_account.php?job=<?php echo $id; ?>"><span><?php echo $Title; ?></span></a>
        <?php } } ?>
        </div>  
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 输入的char字符转为int类型,不是对应的ascall码,如何才能使之转换为对应ascall码?或者使输入的char字符可以正常与其他字符比较?
  • ¥15 解决websocket跟c#客户端通信
  • ¥30 Python调用dll文件输出Nan重置dll状态
  • ¥15 浮动div的高度控制问题。
  • ¥66 换电脑后应用程序报错
  • ¥50 array数据同步问题
  • ¥15 pic16F877a单片机的外部触发中断程序仿真失效
  • ¥15 Matlab插值拟合差分微分规划图论
  • ¥15 keil5 target not created
  • ¥15 C/C++数据与算法请教