예제 #1
0
        }
        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 = [];
        $response1[] = $data;
        $response1[] = $errors;
        $jsondata = json_encode($response1);
        echo $jsondata;
        // $sub_category = new subcategory();
        // $sub_category->sub_cat_name = $_GET['name'];
        // $sub_category->sub_cat_desc = $_GET['desc'];
        // $sub_category->sub_cat_id = $_GET['cat'];
        // $sub_category->insert();
        // $data = $sub_category->getallsubcategory();
        // $jsondata = json_encode($data);
        // echo $jsondata;
    } else {
        $cat = new subcategory();
        $jsondata = json_encode($cat->getallsubcategory());
        echo $jsondata;
    }
}