我想将查询结果打印到表格中。我在查询中设置了一个限制,只能获取 5 行。它确实从我的数据库中获取了 5 行。但是当我将结果打印到 HTML 表中时,结果中的第一行没有打印出来。我找不到我的代码有什么问题。请帮忙!
这是我的做法:
<table style="border:none; width:790px;; margin:10px;" cellpadding="0" cellspacing="0">
<tr>
<th class="header">ID</th>
<th class="header">Client Name</th>
<th class="header">Driver's License</th>
<th class="header">Social Security</th>
<th class="header">Phone Number</th>
<th class="header">Email Address</th>
<th class="header">Date Signed Up</th>
</tr>
<?php
$i=1;
while($row = mysql_fetch_assoc($result)){
if ($i & 1) { //odd rows
echo '<tr>';
echo '<td class="entry_odd">'.$row['cid'].'</td>';
echo '<td class="entry_odd">'.$row['fname'].' '.$row['lname'].'</td>';
echo '<td class="entry_odd">'.$row['license'].'</td>';
echo '<td class="entry_odd">'.$row['ss1'].' / '.$row['ss2'].' / '.$row['ss3'].'</td>';
echo '<td class="entry_odd">'.$row['phone1_1'].'-'.$row['phone1_2'].'-'.$row['phone1_3'];
if ($row['phone1_ext'] != NULL ) {
echo ' ext. '.$row['phone1_ext'].'</td>';
} else {
echo '</td>';
}
echo '<td class="entry_odd">'.$row['email'].'</td>';
echo '<td class="entry_odd">'.$row['registered'].'</td>';
echo '</tr>';
} else { //even rows
echo '<tr>';
echo '<td class="entry_even">'.$row['client_id'].'</td>';
echo '<td class="entry_even">'.$row['fname'].' '.$row['lname'].'</td>';
echo '<td class="entry_even">'.$row['license'].'</td>';
echo '<td class="entry_even">'.$row['ss1'].' / '.$row['ss2'].' / '.$row['ss3'].'</td>';
echo '<td class="entry_even">'.$row['phone1_1'].'-'.$row['phone1_2'].'-'.$row['phone1_3'];
if ($row['phone1_ext'] != NULL ) {
echo ' ext. '.$row['phone1_ext'].'</td>';
} else {
echo '</td>';
}
echo '<td class="entry_even">'.$row['email'].'</td>';
echo '<td class="entry_even">'.$row['registered'].'</td>';
echo '</tr>';
}
$i++;
}
?>