if (isset($_GET['catID']) && isset($_GET['scatID']) && isset($_GET['newName'])) { if (!empty($_GET['catID']) && !empty($_GET['scatID']) && !empty($_GET['newName'])) { $subcategory = new Subcategory(); $subcategory->cID = $_GET['catID']; $subcategory->scID = $_GET['scatID']; $subcategory->scName = $_GET['newName']; $subcategory->update(); $responce = 'done'; } else { $responce = 'all data are required'; } } //-------------------------------- get subcategories of a specific category -------------------------------- if (isset($_GET['selected_cID'])) { if (!empty($_GET['selected_cID'])) { $subcategory = new Subcategory(); $responce = $subcategory->getSubcategories($_GET['selected_cID']); $responce = json_encode($responce); } } //-------------------------------------------- draw table ---------------------------------------------- if (isset($_GET['op'])) { if (!empty($_GET['op'])) { if ($_GET['op'] == 'drawTable') { $subcategory = new Subcategory(); $data = $subcategory->getCorrespondingCat(); $responce = json_encode($data); } } } echo $responce;