Heim  >  Artikel  >  Backend-Entwicklung  >  ThinkPHP在模板中输出变量

ThinkPHP在模板中输出变量

WBOY
WBOYOriginal
2016-08-10 09:07:151131Durchsuche

控制器中

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

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

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

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

其中land是在前台中是一个div的id,id与base是对应关系,例如land为1的div填充500,land为2的div填充400.

具体是这么的:
ThinkPHP在模板中输出变量

前台是一个用HTML做的农场,每块地都有一个ID,也就是我上面说的land的id,有树的土地上会有一个方框,方框里的数就是上面提到的base, 每块地的base是不同的, 按照我上面写的如果用没种树的土地就会不显示了。 现在要做的就是有树的land跟base要对应显示,没树的土地也显示出来。。

回复内容:

控制器中

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

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

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

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

其中land是在前台中是一个div的id,id与base是对应关系,例如land为1的div填充500,land为2的div填充400.

具体是这么的:
ThinkPHP在模板中输出变量

前台是一个用HTML做的农场,每块地都有一个ID,也就是我上面说的land的id,有树的土地上会有一个方框,方框里的数就是上面提到的base, 每块地的base是不同的, 按照我上面写的如果用没种树的土地就会不显示了。 现在要做的就是有树的land跟base要对应显示,没树的土地也显示出来。。

你没有提出你的要求是要做什么?
我这里给个例子:用宽度来诠释这个东西的话,那就是->

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


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

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn