Home > Backend Development > PHP Tutorial > ThinkPHP double loop traversal output related content

ThinkPHP double loop traversal output related content

jacklove
Release: 2023-04-01 08:44:02
Original
2693 people have browsed it

ThinkPHP double loop traversal output

Data table 1 Cat column

Data table 2 In article

$cat= D("Cat");
$in = D("In");$total = $cat -> select();foreach($total as $k => $v){   
     $total[$k]['new'] =$in -> where(array('cat_title' => $v['cat_title'])) -> limit(10) -> select();
      }$this -> assign('total',$total);
Copy after login

view page

<volist name="total" id="v">
                <dl class="noMr">
                    <dt class="comBg senseTle">
                    <a href="__APP__/part/{$v.cat_id}/" title="{$v.cat_title}" target="_blank">{$v.cat_title}</a>
                    </dt>
                    <volist name="v[&#39;new&#39;]" id="vo">
                        <dd>
                            <a class="txtellipsis" href="__APP__/spart/{$vo.in_id}.html" target="_blank" title="{$vo.in_title}">{$vo.in_title}</a>
                            <span>{$vo.in_tm}</span>
                        </dd>
                    </volist> 
                </dl>
            </volist>
Copy after login


This article explains the relevant content of ThinkPHP double loop traversal output. For more related content, please pay attention to the PHP Chinese website.

Related recommendations:

Introduction to the quick start method of ThinkPHP5

Introduction to the steps to use ThinkPHP

Unlockable query

The above is the detailed content of ThinkPHP double loop traversal output related content. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template