2013-09-22 64 views
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'; 

?> 
+0

回聲「「;在關閉while循環後放置 – Salim

回答

1

您正在使用結束表標記成環路

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

使用表關閉標籤退出循環作爲

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