ThinkPHP outputs variables in templates

WBOY
Release: 2016-08-10 09:07:15
Original
1181 people have browsed it

In the controller

<code>    $ao=M('Land');

    $base = $ao-> field('base,land')->where($map)->select();

    $this ->display();</code>
Copy after login
Copy after login
<code>print_r($base);

Array ( [0] => Array ( [base] => 500.00 [land] => 1 ) [1] => Array ( [base] => 400.00 [land] => 2 ) ) //还有很多
</code>
Copy after login
Copy after login

where land is the id of a div in the foreground, and the id is corresponding to the base. For example, a div with land 1 is filled with 500, and a div with land 2 is filled with 400.

The specifics are as follows:
ThinkPHP outputs variables in templates

The front desk is a farm made with HTML. Each piece of land has an ID, which is the ID of the land I mentioned above. There will be a box on the land with trees, and the number in the box is the base mentioned above. , the base of each piece of land is different. According to what I wrote above, if you use land without trees will not be displayed. What needs to be done now is to display the land with trees and the base correspondingly, and also display the land without trees. .

Reply content:

In the controller

<code>    $ao=M('Land');

    $base = $ao-> field('base,land')->where($map)->select();

    $this ->display();</code>
Copy after login
Copy after login
<code>print_r($base);

Array ( [0] => Array ( [base] => 500.00 [land] => 1 ) [1] => Array ( [base] => 400.00 [land] => 2 ) ) //还有很多
</code>
Copy after login
Copy after login

where land is the id of a div in the foreground, and the id is corresponding to the base. For example, a div with land 1 is filled with 500, and a div with land 2 is filled with 400.

The specifics are as follows:
ThinkPHP outputs variables in templates

The front desk is a farm made with HTML. Each piece of land has an ID, which is the ID of the land I mentioned above. There will be a box on the land with trees, and the number in the box is the base mentioned above. , the base of each piece of land is different. According to what I wrote above, if you use land without trees will not be displayed. What needs to be done now is to display the land with trees and the base correspondingly, and also display the land without trees. .

What are you going to do without making your request?
Let me give you an example: if you use width to interpret this thing, it is->

<code><style>
     <volist name="base" id="v_base">
        #div{$v_base.land}{
            width :  {$v_base.base}px;
        }
    </volist>
</style>

<html>
    <volist name="base" id="v_base">
        <div id="div{$v_base.land}">
            宽度测试
        </div>
    </volist>
</html></code>
Copy after login

<code>    <div id="{$vo.land}">{$vo.base}</div></code>
Copy after login

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