fetch(PDO::FETCH_ASSOC); $subCats = array(); if ($row['subName1']) { $subCats[] = array($row['subName1'],$row['subColor1'],$row['subBgrnd1']); } if ($row['subName2']) { $subCats[] = array($row['subName2'],$row['subColor2'],$row['subBgrnd2']); } if ($row['subName3']) { $subCats[] = array($row['subName3'],$row['subColor3'],$row['subBgrnd3']); } if ($row['subName4']) { $subCats[] = array($row['subName4'],$row['subColor4'],$row['subBgrnd4']); } //send subcategories echo $subCats ? json_encode($subCats) : '0'; ?>