HTML code ... Use of two foreach loops
- < Div class="modcontent">
- < %foreach from = $sort Item = s % >
- < Div class="categories">
- < acronym class="icon" > < /acronym>
- < a href="category.php?sort_id=
<% $s .sort_id%> ">
- < strong>< % $s. sort_name%> < /strong>
- < /A >< br />
- < %foreach from = $s. Zi Item = Z % >
- < a href="category.php?sort_id=
<% $z .sort_id%> "
- title = "<% $z .sort_name%>" >
- < % $z. sort_name% >
- < /A >
- < %/foreach% >
- < /div >
- < %/foreach% >
- < /div >
The PHP Code of the PHP classification list is simply to use the Foreach Loop an array and then insert an indexed index pair in this array straight is all sub-categories of each query
- Product Categories
- $ 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);
The above code is the specific way to solve the PHP classification list.
http://www.bkjia.com/PHPjc/446076.html www.bkjia.com true http://www.bkjia.com/PHPjc/446076.html techarticle HTML code ... Use two foreach loop div class = Modcontent%foreach from = $sort item = s% div class = categories Acronym class = Icon/acronym a href = category.php?sort_id=% ...