<?php
while ( $rs = mysql_fetch_array($result) ){
     $arr[]=$rs;
?>
        <?php echo $month==mysql_num_rows($result)?"合计: $month 个月":"&nbsp;"; ?>
         <tr><td width="30%" height="20">
         <?php
         for($i= 0;$i<$month;$i++)
         {
         echo $arr[$i]['date'];
         }
         ?>
         </td><td width="50%"></td></tr>
         <?php
}
?>这样用for能不能显示所有查询到的每行的信息了? 为什么这么多<?php ?> ? 就一个不好吗? 原码是别人写的,我刚改了下。PHPMySQL

解决方案 »

  1.   

    为什么呢?为什么会是重复输出?我for里面不是可以跳出循环的吗?
      

  2.   

    在你的程序开始处加上
    error_reporting(E_ALL);你就可以知道都是哪里出错了!
      

  3.   

      <?php
    while ( $rs = mysql_fetch_rows($result) ){
         $arr[]=$rs;
    ?>
            <?php echo $month=mysql_num_rows($result) "合计: $month 个月"; ?>
             <tr><td width="30%" height="20">
             <?php
             for($i= 0;$i<$month;$i++)
             {
             echo $arr[$i]['cust_date'];
             }
             ?>
             </td><td width="50%"></td></tr>
             <?php
    }
    ?>
    这样呢? 我这个电脑没装PHP