<?php
include 'include/db.php';
include 'include/connect.php';
$id = $_POST['id'];

if(!empty($id) && $_POST['name'] != "0"){

                $data['pri_img'] = $_POST['pri_img'];
                $data['pri_name'] = $_POST['pri_name'];
                $data['pri_c'] = $_POST['pri_c'];
                $data['pri_text'] = $_POST['pri_text'];
                
		$rs = $db->update('tbpri',$data,'pri_id',$id);
           if($rs){
            echo "0";
           } else {
            echo "00";
           }

     } else {

      if($_POST['name'] != "0") {
           
      $rs = $db->insert('tbpri',array(
       'pri_name' => $_POST['pri_name'],
       'pri_c' => $_POST['pri_c'],
       'pri_text' => $_POST['pri_text'],
       'pri_img' => $_POST['pri_img']
            ));

           if($rs){
            echo "2";
           } else {
            echo "0";
           }
         } else {
            echo "3";
        }
}
?>

