1

结果本身没有任何问题。

图像应该自我解释。

该表基本上是为每个结果重复整个表,而不是在一个表上显示多行的结果,它在 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++;
}
?>
4

1 回答 1

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>  
于 2013-06-04T01:17:29.630 回答