结果本身并没有错。
图像应该解释自己。
该表基本上是为每个结果重复整个表,而不是在一个表上显示多行的结果,它在1个表上多次执行1行。
以下是涉及它的代码 -
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"id");
$f2=mysql_result($result,$i,"date");
$f3=mysql_result($result,$i,"agentclient");
$f4=mysql_result($result,$i,"propertydescription");
$f5=mysql_result($result,$i,"transactiontype");
$f5=mysql_result($result,$i,"applicabledocument");
$f5=mysql_result($result,$i,"received");
$f5=mysql_result($result,$i,"paid");
?>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr valign="bottom" bgcolor="#000000">
<td width="24"><span class="style1b"><strong>No.</strong></span></td>
<td width="105"><span class="style1b"><strong>Date</strong></span></td>
<td width="57"><span class="style1b"><strong>Agent/client</strong></span></td>
<td width="170"><span class="style1b"><strong>Property/Description</strong></span></td>
<td width="199"><span class="style1b"><strong>Transaction type </strong></span></td>
<td width="235"><span class="style1b"><strong>Applicable document </strong></span></td>
<td width="58"><span class="style1b"><strong>Received</strong></span></td>
<td width="58"><span class="style1b"><strong>Paid</strong></span></td>
</tr>
<tr valign="top" bgcolor="#FFFFFF">
<td><?php echo $f1; ?></td>
<td><?php echo $f2; ?></td>
<td><?php echo $f3; ?></td>
<td><?php echo $f4; ?></td>
<td><?php echo $f5; ?></td>
<td><?php echo $f6; ?></td>
<td><?php echo $f7; ?></td>
<td><?php echo $f8; ?></td>
</tr>
</table>
<?php
$i++;
}
?>
答案 0 :(得分:1)
有很多方法可以改进这段代码,但为了解决你的问题,只需将标题行排除在循环之外:
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr valign="bottom" bgcolor="#000000">
<td width="24"><span class="style1b"><strong>No.</strong></span></td>
<td width="105"><span class="style1b"><strong>Date</strong></span></td>
<td width="57"><span class="style1b"><strong>Agent/client</strong></span></td>
<td width="170"><span class="style1b"><strong>Property/Description</strong></span></td>
<td width="199"><span class="style1b"><strong>Transaction type </strong></span></td>
<td width="235"><span class="style1b"><strong>Applicable document </strong></span></td>
<td width="58"><span class="style1b"><strong>Received</strong></span></td>
<td width="58"><span class="style1b"><strong>Paid</strong></span></td>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"id");
$f2=mysql_result($result,$i,"date");
$f3=mysql_result($result,$i,"agentclient");
$f4=mysql_result($result,$i,"propertydescription");
$f5=mysql_result($result,$i,"transactiontype");
$f5=mysql_result($result,$i,"applicabledocument");
$f5=mysql_result($result,$i,"received");
$f5=mysql_result($result,$i,"paid");
?>
<tr valign="top" bgcolor="#FFFFFF">
<td><?php echo $f1; ?></td>
<td><?php echo $f2; ?></td>
<td><?php echo $f3; ?></td>
<td><?php echo $f4; ?></td>
<td><?php echo $f5; ?></td>
<td><?php echo $f6; ?></td>
<td><?php echo $f7; ?></td>
<td><?php echo $f8; ?></td>
</tr>
<?php
$i++;
}
?>
</table>