<?php 
require_once '../config/db.php';
require_once '../config/database.class.php';
require_once '../config/functions.php';
$d = new database($db_config);


if(isset($_POST)){
	$post  =$_POST;
	$subcategory = $post['subcategory'];
    $product = $post['product'];
    
    $description = $post['description'];
    $choose = $post['choose'];
    $delivery = $post['delivery'];
   
  
  
	if($post['id']==''){
    $query = "INSERT INTO Product_description (`subcategory`,`product`,`description`,`choose`,`delivery`) VALUES('$subcategory','$product','$description','$choose','$delivery')";
        $executeQuery = $d->insertQuery($query);
        if($executeQuery){
        	echo getResponse('success','Data saved successfully');
        }else{
        	echo getResponse('error','Something went wrong, please try later!');
        }
	}else{
$id = $post['id'];
		$query = "UPDATE Product_description SET subcategory='".$subcategory."',product='".$product."',description='".$description."',choose='".$choose."',delivery='".$delivery."' WHERE id=$id";
        $executeQuery = $d->updateQuery($query);
        if($executeQuery){
        	echo getResponse('success','Data updated successfully');
        }else{
        	echo getResponse('error','Something went wrong, please try later!');
        }

	}
}
?>