I am fetching the category and subcat information from database as follows:
$cols=array("id","name","description","tags","subcat","img");
$result=$conn->get("category",null,$cols);`
Note that result is a multidimentional array like $result[0]['name'] will display category name and $result[0]['subcat'] will display first category and subcategory respectively.
Here is the rest of the snippet:
$subcat="Notset";
$cat=array();
$sub=array();
$j=0;
for ($i=0;$i<$conn->count; $i++)
{
if($result[$i]['subcat'] != $subcat)
{
$subcat=$result[$i]['subcat'];
$sub[$j]=$subcat;
$j++;
}
$cat[$i]=$result[$i]['name'];
}
But i an getting result as follows: Snapshot of web page
But i want to display sony under desktop category and macbook under laptop category please help.In the above image red button is category green is for subcategory.

var_dump($result);after the line$result=$conn->get("category",null,$cols);- jetblack$result[$i]['subcat']is notNotset. You're not actually checking which parent it's under. - Rocket Hazmat