<?php 
session_start();
include('../includes/dbcon.php');

$str=" ";





$cat_des= mysqli_real_escape_string($con,trim($_POST['cat_des']));
$catid_edit= mysqli_real_escape_string($con,trim($_POST['catid_edit']));

$query=mysqli_query($con," select * from item_category where cat_des='$cat_des'  ")or die(mysqli_error($con));
    $count=mysqli_num_rows($query);
if ($count>0)
{
	echo "<script type='text/javascript'>alert('Exsisting Category!');</script>";
	echo "<script>document.location='admin_cat_view.php'</script>"; 
}

else {	
		
	if ( mysqli_query($con,"update item_category set cat_des = '$cat_des'
	  where cat_id=$catid_edit ")or die(mysqli_error($con)))
		{
			echo "<script>document.location='admin_cat_view.php'</script>"; 
		}		

}

?>