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>  

图片转代码服务由CSDN问答提供 功能建议

我执行流动的代码我希望在列表中显示所有应用的作业但在我的代码中它只显示第一个 job&gt;&gt;&gt;请如果有人知道帮助我....

 &lt;?php 
 include(“includes / db.php”); \  n 
 ///////////////////////////////////////////////  /////////////// 
 //获取求职者的个人信息
 // $ 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'];  
 //获取jobseeker aplication 
 $ get_app =“select * from job_application,其中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']; 
 //获取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 ++; 
 
 
?&gt; 
&lt; div class =“list-group”&gt; 
&lt; a class =“list-group-item”href =“my_account.php?job  =&lt;?php echo $ id;?&gt;“&gt;&lt; span&gt;&lt;?php echo $ Title;  ?&gt;&lt; / span&gt;&lt; / a&gt; 
&lt;?php}?&gt; 
&lt; / div&gt;  
   
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

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>  
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题