// For Generating Array Parent & Child Wise
$this->dash_model->cattest(0));
public function cattest($parent_id) {
$sqlquery = " SELECT * FROM categories where parent='" .$parent_id . "' ";
$row = $this->db->query($sqlquery)->result_array();
$allCategory = array();
if(count($row)>0){
foreach ($row as $value){
$tempCat = array();
$cat_id = $value['id'];
$tempCat['categoty_details'] = $value;
//has sub category
$hasSubCat = $this->cattest($cat_id);
if(count($hasSubCat) >0 ){
$tempCat['has_sub'] = 'Y';
$tempCat['sub_category'] = $this->cattest($cat_id);
//unset($tempCat['sub_category']);
}else{
$tempCat['has_sub'] = 'N';
}
array_push($allCategory, $tempCat);
}
}
return $allCategory;
}