【急】php Smarty 二维树形菜单
我想知道后台数据是怎么操作的?比如现在有表category与product。。我想知道后台数据怎么放入数组中?...
我想知道后台数据是怎么操作的?比如现在有表category与product 。。我想知道后台数据怎么放入数组中?
展开
2个回答
展开全部
php文件
<?php
$tpl = New Smarty();
$Class = array(array("bigid" => "1","bigname" => "粮油2","Small" => array(array("ID" => "1","Name"=>"稻谷"),array("ID" => "2","Name"=>"麦类"),array("ID" => "3","Name"=>"玉米"),array("ID" => "4","Name"=>"花生"),array("ID" => "5","Name"=>"豆类"))),array("bigid" => "2","bigname" => "蔬菜及制成品","Small" => array(array("ID" => "1","Name"=>"竹笋类"),array("ID" => "2","Name"=>"花菜类"),array("ID" => "3","Name"=>"芥菜类"),array("ID" => "4","Name"=>"甘蓝类"),array("ID" => "5","Name"=>"绿叶绿叶绿叶类"),array("ID" => "6","Name"=>"绿叶绿叶绿叶类"),array("ID" => "7","Name"=>"绿叶类"))),array("bigid" => "3","bigname" => "蔬菜及制成品","Small" => array(array("ID" => "1","Name"=>"竹笋类"),array("ID" => "2","Name"=>"花菜类"),array("ID" => "3","Name"=>"芥菜类"),array("ID" => "4","Name"=>"甘蓝类"),array("ID" => "5","Name"=>"绿叶绿叶绿叶类"),array("ID" => "6","Name"=>"绿叶绿叶绿叶类"),array("ID" => "7","Name"=>"绿叶类"))));
$tpl-> assign("Class",$Class);
?>
tpl文件
<ul id="cla_cen">
<li>
{*产品分类*}
{section name=big loop=$Class}
<h4><a href="#Big{$Class[big].bigid}">{$Class[big].bigname}</a></h4>
{section name=small loop=$Class[big].Small}
<a href="#Small{$Class[big].Small[small].ID}">{$Class[big].Small[small].Name}</a> |
{/section}
<br>
{/section}
</li>
</ul>
<?php
$tpl = New Smarty();
$Class = array(array("bigid" => "1","bigname" => "粮油2","Small" => array(array("ID" => "1","Name"=>"稻谷"),array("ID" => "2","Name"=>"麦类"),array("ID" => "3","Name"=>"玉米"),array("ID" => "4","Name"=>"花生"),array("ID" => "5","Name"=>"豆类"))),array("bigid" => "2","bigname" => "蔬菜及制成品","Small" => array(array("ID" => "1","Name"=>"竹笋类"),array("ID" => "2","Name"=>"花菜类"),array("ID" => "3","Name"=>"芥菜类"),array("ID" => "4","Name"=>"甘蓝类"),array("ID" => "5","Name"=>"绿叶绿叶绿叶类"),array("ID" => "6","Name"=>"绿叶绿叶绿叶类"),array("ID" => "7","Name"=>"绿叶类"))),array("bigid" => "3","bigname" => "蔬菜及制成品","Small" => array(array("ID" => "1","Name"=>"竹笋类"),array("ID" => "2","Name"=>"花菜类"),array("ID" => "3","Name"=>"芥菜类"),array("ID" => "4","Name"=>"甘蓝类"),array("ID" => "5","Name"=>"绿叶绿叶绿叶类"),array("ID" => "6","Name"=>"绿叶绿叶绿叶类"),array("ID" => "7","Name"=>"绿叶类"))));
$tpl-> assign("Class",$Class);
?>
tpl文件
<ul id="cla_cen">
<li>
{*产品分类*}
{section name=big loop=$Class}
<h4><a href="#Big{$Class[big].bigid}">{$Class[big].bigname}</a></h4>
{section name=small loop=$Class[big].Small}
<a href="#Small{$Class[big].Small[small].ID}">{$Class[big].Small[small].Name}</a> |
{/section}
<br>
{/section}
</li>
</ul>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询