1

希望你能帮忙。我正在运行查询,但没有显示任何结果,这只是当我尝试将结果字段的 2 与另一个链接时请帮忙?

这是我的代码

<?php
include 'core/init.php';
include 'includes/overall/header.php';
?>
<div class="article">
<?php

$result = mysqli_query($con,"SELECT * FROM ref_employees");


while($row = mysqli_fetch_array($result))
if(($user_data['user_id']) == 'employerid'){
  {


    echo '<h4>  ID                  :  '.$row['idnumber'] ;
    echo '<br>  First Name          :  '.$row['firstname'];
    echo '<br>  Last Name           :  '.$row['lastname'];
    echo '<br>  Reference 1       :  '.$row['ref1'];
    echo '<br>  Reference 2    :  '.$row['ref2'];
     echo '<br>  Reference 3    :  '.$row['ref3'];
      echo '<br>  Gender    :  '.$row['gender'];
      echo '<br>  EMP ID    :  '.$row['employerid'];
      echo '<br>  employed     :  '.$row['employed'];
    echo ' </h4>';
  include 'includes/adminmenu.php';

   } 
}


mysqli_close($con);?>
</div>

<?php include 'includes/overall/footer.php';

?>
4

1 回答 1

0

这一行:

if(($user_data['user_id']) == 'employerid'){

应该:

if(($user_data['user_id']) == $row['employerid']){

但是,如果您只需要这样,您可以通过查询确切的 ID 来节省一些资源和代码。

SELECT * FROM ref_employees WHERE employerid={$user_data['user_id']}

您还在 while() 循环中放错了一个 { 。

while($row = mysqli_fetch_array($result))
if(($user_data['user_id']) == 'employerid'){
  {

应该:

while($row = mysqli_fetch_array($result))
{
  if(($user_data['user_id']) == 'employerid'){
于 2013-09-22T09:27:19.133 回答