时间:2021-07-01 10:21:17 帮助过:13人阅读
- <!--?php
- while ( $rs = mysql_fetch_array($result) ){
- $arr[]=$rs;
- ?-->
- <!--?php echo $month==mysql_num_rows($result)?"合计: $month 个月":" "; ?-->
- <!--?php
- for($i= 0;$i<$month;$i++)
- {
- echo $arr[$i]['date'];
- }
- ?-->
- <!--?php
- }
- ?-->
你这个变成嵌套循环了,估计是你逻辑错误了,你想的应该是先把数据库中数据保存在数组中,然后在一个循环将数据输出,但是你现在就重复输出了。
为什么呢?为什么会是重复输出?我for里面不是可以跳出循环的吗?
你运行下你代码不就知道结果了
在你的程序开始处加上
error_reporting(E_ALL);
你就可以知道都是哪里出错了!
- <!--?php
- while ( $rs = mysql_fetch_rows($result) ){
- $arr[]=$rs;
- ?-->
- <!--?php echo $month=mysql_num_rows($result) "合计: $month 个月"; ?-->
- <!--?php
- for($i= 0;$i<$month;$i++)
- {
- echo $arr[$i]['cust_date'];
- }
- ?-->
- <!--?php
- }
- ?-->