from this query
[code]
$categorysubcategorydescripttitle = $connect->query(“SELECT CategoryTitle, SubCategoryTitle, SubCategoryDescription_Lrg FROM lkuTbl_Category LEFT JOIN lkuTbl_SubCategory ON FK_CategoryId = PK_CategoryId”);
while($catsubcat_descripttitle = $categorysubcategorydescripttitle->fetch_assoc()) {
print_r($catsubcat_descripttitle);
}
I get the following in form of an associative array
[code]
Array
(
[CategoryTitle] => Traditional Favourites
[SubCategoryTitle] => Dosai
[SubCategoryDescription_Lrg] => Pancake or crepe made from a fermented batter of rice flour and urid dhal (black gram/ lentil) served with sambar (a lentil based vegetable stew or chowder, cooked with tamarind broth and seasoned with exotic spices) along with two chutneys
)
Array
(
[CategoryTitle] => Traditional Favourites
[SubCategoryTitle] => Steamed Rice Cakes
[SubCategoryDescription_Lrg] => Type of savoury rice cakes made by steaming a fermented batter consisting of rice flour and urid dhal (black gram/ lentil) served with sambar (a lentil based vegetable stew or chowder, cooked with tamarind broth and seasoned with exotic spices) along with two chutneys
)
Array
(
[CategoryTitle] => Traditional Favourites
[SubCategoryTitle] => Crispy Breads
[SubCategoryDescription_Lrg] =>
)
Array
(
[CategoryTitle] => Starters
[SubCategoryTitle] =>
[SubCategoryDescription_Lrg] =>
)
Array
(
[CategoryTitle] => Mains
[SubCategoryTitle] =>
[SubCategoryDescription_Lrg] =>
)
but WHAT I’M TRYING TO ACHIEVE IS SOMETHING LIKE BELOW:
[code]
Array
(
[Traditional Favourites] => Array
(
[SubCategoryTitle] => Dosai
[SubCategoryTitle] => Steamed Rice Cakes
[SubCategoryTitle] => Crispy Breads
)
)
but what I’ve got is this below:
[code]
Array
(
[Traditional Favourites] => Array
(
[SubCategoryTitle] => Dosai
)
)
Array
(
[Traditional Favourites] => Array
(
[SubCategoryTitle] => Steamed Rice Cakes
)
)
Array
(
[Traditional Favourites] => Array
(
[SubCategoryTitle] => Crispy Breads
)
)
Using the below:
[code]
$categorysubcategorydescripttitle = $connect->query(“SELECT CategoryTitle, SubCategoryTitle, SubCategoryDescription_Lrg FROM lkuTbl_Category LEFT JOIN SubCategory ON FK_CategoryId = PK_CategoryId”);
while($catsubcat_descripttitle = $categorysubcategorydescripttitle->fetch_assoc()) {
foreach($catsubcat_descripttitle as $key => $value) {
if($key == ‘SubCategoryTitle’ && ($value != NULL | $value != ”)) {
$subcategory_title[$key] = $value;
}
}
if($catsubcat_descripttitle[‘CategoryTitle’] == “Traditional Favourites”) {
$catsubcat[$catsubcat_descripttitle[‘CategoryTitle’]] = $subcategory_title;
print_r($catsubcat);
}
}
// while($catsubcat_descripttitle = $categorysubcategorydescripttitle->fetch_assoc())
can someoe possibly help? please
__(Added some more `[code]…[/code]