duaj39673 2016-09-26 18:26
浏览 155
已采纳

如何从@foreach中获取最小数量的<tr>? [关闭]

I have a data set that I need to output to a pdf. I am building the pdf in a view and then using dompdf to generate. I am trying to get the pdf to resemble a printed form used for the same data. I'd like to run one @foreach to create the table rows but have it generate a set number of rows whether there is data or not.

For instance, I'd like to generate 15 rows in the table even if there are only 10 records and complete the table with 5 empty rows.

How can I do this?

Thanks.

  • 写回答

2条回答 默认 最新

  • dronthpi05943 2016-09-26 18:44
    关注

    Simple thing :)

    <?php $N=0; ?>
    @foreach($data AS $row)
    <tr>
      <td>{{ ++$N }}</td>
      ...
    </tr>
    @endforeach
    
    @for($i=1; $i<=15-sizeof($data); $i++)
    <tr>
      <td>{{ ++$N }}</td>
      ...
    </tr>
    @endfor
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码