• ThinkPHP数据多维数组遍历


    记录遍历

    目的:

    AB类:
    AB AAB BBA ABAB
    CD类:
    CD CCD CDD CDCD

    控制器

    foreach ($list as $k => $v) {
         $list[$k]["Ipsix"]=$Ipsix->where(array('Ipsix_form_name'=>$v['Ipsix_form_name']))->select();
    }

    前端

    <volist name="list" id="list" key="k" empty="当前无内容">                    
          <if condition="$list.Ipsix eq false">
              <td style="font-size:12px;">
                   0
               </td>
          <else />
               <volist name="list.Ipsix" id="Ipsix">
              <td style="font-size:12px;">
                  {$Ipsix.Ipsix_name}
              </td>
               </volist>
           </if>
    </volist>

    数量结果引入查询

    目的:

    数据表A

    第一条记录需要引入B表中数量插入,如下图

    控制器

    foreach ($list as $k => $v) {
         $list[$k]["Ipsixcount"]=$Ipsix->where(array('Ipsix_form_name'=>$v['Ipsix_form_name']))->count();
    }

    前端

    <volist name="list" id="list" key="k" empty="当前无内容">                    
          <if condition="$list.Ipsixcount eq false">
              <td style="font-size:12px;">
              0
               </td>
          <else />
          <td style="font-size:12px;"> 
            {$list.Ipsixcount}
         </td> </if> </volist>

    本文来自博客园,作者:袁与张,转载请注明原文链接:https://www.cnblogs.com/ytyzhn/p/14689740.html

  • 相关阅读:
    luogu2253 好一个一中腰鼓!
    luogu2948 滑雪课
    luogu1556 幸福的路
    luogu1900 自我数
    luogu1632 点的移动
    luogu1999 高维正方体
    树状数组模板
    杜教筛
    [比赛|考试] 9月第一周的考试
    历年NOIP真题总结
  • 原文地址:https://www.cnblogs.com/ytyzhn/p/14689740.html
Copyright © 2020-2023  润新知