![]() |
Foreach Loop
I'm trying loop categories so I get main category then the sub cats listed below them for a download section mod I'm building.
Here's the code thus far: PHP Code:
Steve |
And the problem is?
|
Oh sorry, the problem is that they will display but I'm not sure how to get them to display like so:
Main Cat 1 - SubCat2 | - SubCat3 - SubCat4 Main Cat 2 - SubCat5 | - SubCat6 - SubCat7 | - SubCat8 But all I get from that foreach is a list of all categories that just repeat. So maybe I'm missing something. Thanks Steve |
Why not just select all the categories and order them in an array properly in a single loop? You will be generating quite a few queries with your current method....
|
Actually, what you suggested Danny is what I'm trying but failing horribly. Any code suggestions?
|
Please provide the table structure and sample data.
|
it's a simple structure with only one level of subcategories right ?
PHP Code:
|
Something like:
PHP Code:
|
Tefra: sub_cat is no longer used, all I use now is par_cat. Here is an updated piece of code.
PHP Code:
HTML Code:
<if condition="$number_cats == '0'">do nothing<else />begin displaying sub cats</if> PHP Code:
Now the foreach confused me because I don't use sub_cat any longer, if you could redo the example using par_cat. Danny.VBT, your more than welcome to answer my questions above. Now the example code you posted I didn't understand, can you explain each portion or what its doing example wise? Thanks Steve |
I suggest you one really helpful change to calculate the total entries of each category during the add,delete,move of the download entries. This way you will save the count query.
PHP Code:
|
All times are GMT. The time now is 03:30 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|