Small annoyance with arrays here. Been hacking at it since 9am this morning and only managed to get half way through (not through want of trying & failing :( ). Hoping someone can point me in the right direction.
Here's the PHP code I have to get my data into the array structure I think is required;
if$arrCategories = $db-get_resultsSELECT id, strCategoryName FROM tbl_categories WHERE intFlag = 1 ORDER BY intOrder ASC;
$intJSCount = 1; //required for something else
$arrDynMenu = array;
foreach$arrCategories as $category
array_push$arrDynMenu$category-strCategoryName = array;
if$arrSubCategories = $db-get_resultsSELECT id, strSubCategoryName FROM tbl_subcategories WHERE intFlag = 1 AND intMenuID = .$category-id. ORDER BY intOrder ASC;
foreach$arrSubCategories as $subcategory
array_push$arrDynMenu$category-strCategoryName, array'id'=$subcategory-id,'strSubCategory'=$subcategory-strSubCategoryName;
$intJSCount++;
I'm using ez_sql so ignore the SQL statements - they do what I want.
Here's the array output of "$arrDynMenu";
Array
Jackets = Array
0 = Array
id = 4
strSubCategory = PC
1 = Array
id = 5
strSubCategory = Argyle
2 = Array
id = 6
strSubCategory = Baru
Kilts = Array
0 = Array
id = 1
strSubCategory = Long
1 = Array
id = 3
strSubCategory = Short
2 = Array
id = 2
strSubCategory = Medium
What I'm trying to get to is having the vLibTemplate coding within the HTML page displaying it similar to this;
Jackets
4 PC
5 Argyle
6 Baru
Kilts
1 Long
2 Short
3 Medium
I tried to hack about with the loops code in the examples, but since there's an extra array in my effort, I failed :o
Any help is much appreciated & thanks in advance.