예제 #1
0
     $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 = [];
 $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;
예제 #2
0
<?php

include 'categoryclass.php';
include 'subcategoryclass.php';
$cat = new category();
$c = $cat->category();
if (isset($_POST['Add'])) {
    if (!empty(trim($_POST['subcatname']))) {
        $subcat = new subcategory();
        $Type_id = $_POST['catname'];
        $scatname = $_POST['subcatname'];
        $subcat->insert($scatname, $Type_id);
    }
}
include 'header1.php';
?>
<form action="addSubcategory.php" method="post">	
<div id="inside">
	<div class="container">
	<div class="row">
    <table class="table table-bordered table-hover table-striped table-responsive">
		<tr><th colspan="2"><h2>Add new subcategory</h2></th></tr>
		<tr>
			<th>category name</th>

			<td><select name="catname">
			<?php 
foreach ($c as $key => $value) {
    $cat_id = $value['tid'];
    $name = $value['name'];
    echo "<option value='{$cat_id}'>{$name}</option> ";