0

レコードを表示するために実行されたクエリからのレコードの出力に問題があります....コードが指定するように最初の行のみを表示し、次の結果はすべて..段落に表示されますか? 関係あるかは知らん

<?php
include 'core/init.php';
include 'includes/overall/header.php';
?>
<div class="article" style="width:900px !important">
<?php

$result = $sql = mysql_query("SELECT * FROM ref_employees WHERE employerid={$user_data['user_id']} ")
   or die('Error in query : $sql. ' .mysql_error());
      echo "<table border='0' class='table'>
<tr>
<th>ID Number</th>
<th>Employee Number</th>
<th>FirstName</th>
<th>LastName</th>
<th>MiddleName</th>
<th>Job Title</th>
<th>Employement Status</th>
<th>Contact</th>
<th>Email</th>
<th>Edit</th>
</tr>";

if (mysql_num_rows($sql) > 0) 
{            


while ($row = mysql_fetch_array($sql)){

    if ($row['employed'] == '1'){

 echo "<tr>";
    echo "<td>" . $row['idnumber'] . "</td>";
    echo "<td>" . $row['empnumber'] . "</td>";
    echo "<td>" . $row['firstname'] . "</td>";
    echo "<td>" . $row['lastname'] . "</td>";
    echo "<td>" . $row['middlename'] . "</td>";
    echo "<td>" . $row['jobtitle'] . "</td>";
    echo "<td>" . $row['employed'] . "</td>";
    echo "<td>" . $row['contactnum'] . "</td>";
    echo "<td>" . $row['contactemail'] . "</td>";
    echo "<td>" . $row['FirstName'] . "</td>";
     echo "</tr>";
  echo "</tr>";
  echo "</table>";
  }



   } 
}

?>
</div>

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

?>
4

1 に答える 1

1

次のように、終了テーブルタグをループに使用しています

while ($row = mysql_fetch_array($sql)){
    ....
    ....
    ...
    echo "</table>";
}

ループ外でテーブル終了タ​​グを使用する

while ($row = mysql_fetch_array($sql)){
    ....
    ....
    ...
}
echo "</table>";
于 2013-09-22T15:02:54.410 に答える