douduxia1551 2011-08-30 10:44
浏览 43
已采纳

循环前打印计数?

<div class="biz_gary_btn fl width81 mt10">
  <div class="pl10 pr10" onclick="javascript:catsub();">Subscribe</div>
 </div>
 <div class="arial bold fnt12 c2f4792 underline fl pl20 pt5"><?php echo $count; ?> Feeds</div>// Here I am going to print my count !!!! but the count will be incremented here
</div>
</div>



<div id="arrow_content" class="fl cl pl10 arial bold fnt11 c2f4792 answer width500">
<div class="clearfix pb10"><!--Subscribe 2nd loop starts here -->
<div class="fl">
   <div class="fl"><img src="images/orange_tab.png" /></div>
   <div class="fl pl10 c666">Feeds on this Bundle</div>
</div><?php foreach($cat['sub_category'] as $sub_cat) 
{           //echo ($count);
?>  
                <style>
                        #subscribe_chk<?php echo $sub_cat['id'];?>.checked{
                           background: url(<?php echo base_url();?>images/pre_checked.jpg) no-repeat;
                           background-position:0px 2px;
                        }
                </style>
<div class="cl pre_check fl pt10">
   <input id="sub_chk<?php echo $sub_cat['id'];?>" value="<?php echo $sub_cat['id'];?>" name="sub_id" onclick="send_value(this.value)" type="checkbox" />
   <label id="subscribe_chk<?php echo $sub_cat['id'];?>" for="sub_chk<?php echo $sub_cat['id'];?>" class="pl5" style="background-color:#FFFFFF;" ><?php echo $sub_cat['sub_category'];?></label>
</div>

<?php $count++; ?>// here I am incrementing the count. How do i print it before the loop
<?php } ?>
  • 写回答

2条回答 默认 最新

  • dt3358 2011-08-30 10:46
    关注
    echo count($cat['sub_category']);
    

    is correct

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式