// echo $jsondata; } if ($_GET['value'] == 'Edit') { $sub_category = new subcategory($_GET['id']); $jsondata = json_encode($sub_category); echo $jsondata; } } else { if (isset($_GET['value'])) { $errors = []; $sub_category = new subcategory(); if (empty(trim($_GET['name']))) { $errors[] = "the name is empty"; $_SESSION['errors'] = $errors; } if ($sub_category->subcategory_is_exist($_GET['cat'], $_GET['name'])) { $errors[] = "the subcategory is already exist"; $_SESSION['errors'] = $errors; } if (empty(trim($_GET['desc']))) { $errors[] = "the desc is empty"; $_SESSION['errors'] = $errors; } if (empty($errors)) { $sub_category->sub_cat_name = $_GET['name']; $sub_category->sub_cat_desc = $_GET['desc']; $sub_category->cat_id = $_GET['cat']; $sub_category->insert(); } $data = $sub_category->getallsubcategory(); $response1 = [];