您好,欢迎访问一九零五行业门户网

运用循环实现PHP分类列表_PHP教程

html代码...用到两个foreach 循环
div class=modcontent>   %foreach from=$sort item=s%>   div class=categories>   acronym class=icon> /acronym>  a href=category.php?sort_id=
>  strong> %$s.sort_name%> /strong>  /a> br />   %foreach from=$s.zi item=z%>   a href=category.php?sort_id=
  title=>  %$z.sort_name%>  /a>      %/foreach%>   /div>     %/foreach%>   /div> 
php分类列表之php代码 简单的说就是利用foreach 循环一个数组然后在这个数组里插入一个索引 索引对的直就是每次查询的所有子分类
//商品分类  $sql=select * from `hcl_sort` 
where `parent_id`=0 order by 
`sort_id` desc;  $sort=$db->getall($sql);  foreach ($sort as $key=>$val){  $sort_id=$sort[$key]['sort_id'];  $sql=select * from `hcl_sort`
 where `parent_id`={$sort_id};  $zi=$db->getall($sql);  $sort[$key]['zi']=$zi;  }  $tpl->assign('sort',$sort); 
以上代码就是php分类列表的具体解决方法。
http://www.bkjia.com/phpjc/446076.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/446076.htmltecharticlehtml代码...用到两个foreach 循环 div class = modcontent %foreach from =$sort item = s % div class = categories acronym class = icon /acronym a href = category.php?sort_id= %...
其它类似信息

推荐信息