Use loops to implement the PHP classification list. Html code... two foreach loops are used: divclassmodContent % foreachfrom $ sortitems % divclasscategoriesacronymclassiconacronymahrefcategory. php? Sort_id %
Html code... two foreach loops are used
- < PClass = "modContent">
- <% Foreach from = $ sort item = s %>
- < PClass = "categories">
- < AcronymClass = "icon"> </Acronym>
- < AHref = "category. php? Sort_id =
<% $ S. sort_id %>">
- < Strong> <% $ S. sort_name %> </Strong>
- </> < Br />
- <% Foreach from = $ s. zi item = z %>
- < AHref = "category. php? Sort_id =
<% $ Z. sort_id %>"
- Title = "<% $ z. sort_name %>">
- <% $ Z. sort_name %>
- </>
- <%/Foreach %>
- </P>
- <%/Foreach %>
- </P>
PHP code for the PHP classification list is simply to use foreach to loop through an array and insert an index to this array. The result is that all subcategories are queried each time.
- // Product category
- $ SQL = "SELECT * FROM 'hcl _ sort'
WHERE 'parent _ id' = 0 ORDER
'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 solution to the PHP classification list.
Loop p class = modContent % foreach from = $ sort item = s % p class = categories acronym class = icon/acronym a href = category. php? Sort_id = %...