在php中显示表中的多个列表项
我做流动代码我想在一个列表中显示所有申请的工作,但在我的代码中只显示第一个工作>>>请如果有人知道帮助我在php中显示表中的多个列表项,php,list,row,Php,List,Row,我做流动代码我想在一个列表中显示所有申请的工作,但在我的代码中只显示第一个工作>>>请如果有人知道帮助我 <?php include("includes/db.php"); ////////////////////////////////////////////////////////////// //get jobseeker personal information //$user=$_SESSION['Email'];
<?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>
一个求职申请有更多的求职实体,还是一个求职者有更多的求职申请 我认为合适的代码应该是:
<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>
应在while no之前?除此之外,我看不出有什么问题。能否输出查询结果:$run\u job?停止使用大写变量。PHP对大小写很敏感,在您的用例中,它不会提高可读性。为什么要大写$Title
而不是$i
?@bleuscyther结果只有第一项显示是的,它有更多的实体和求职者申请了多份工作是的,这更有意义