<?php 
include("includes/db_config.php");
$id=$_GET["id"];
error_reporting(E_ALL);
ini_set('display_errors','1');
$sql="select sub_category.sub_category_name,sub_category.id as scat_id,category.cat_name,category.id as cid,sub_sub_category.sub_sub_cat_name,sub_sub_category.id sscate_id,product.* from product join category on product.category_id=category.id join sub_category on product.sub_category_id=sub_category.id join sub_sub_category on product.sub_sub_cat_id=sub_sub_category.id where product.id='$id'";
$result = mysqli_query($conn, $sql); 

if(isset($_POST['update']))
{
extract($_POST);
$id=$_POST["id"];
$cat_id=$_POST["category"];
$subcat_id=$_POST["sub_category"];
$subsub_catid=$_POST["sub_sub_category"];
$product_name=$_POST["prod_name"];
$sql_cat="SELECT * from category where id='$cat_id'";
$exe_cat=mysqli_query($conn,$sql_cat);
$res_cat=mysqli_fetch_array($exe_cat);
$category = strtolower(str_replace(" ", "-", $res_cat['cat_name']));
$sql_scat="SELECT * from sub_category where id='$subcat_id'";
$exe_scat=mysqli_query($conn,$sql_scat);
$res_scat=mysqli_fetch_array($exe_scat);
$subcategory = strtolower(str_replace(" ", "-", $res_scat['sub_category_name']));
$sql_sscat="SELECT * from sub_sub_category where id='$subsub_catid'";
$exe_sscat=mysqli_query($conn,$sql_sscat);
$res_sscat=mysqli_fetch_array($exe_sscat);
$subsubcategory = strtolower(str_replace(" ", "-", $res_sscat['sub_sub_cat_name']));
if(file_exists('../$category/$subcategory/$subsubcategory')){
  if(strtolower(str_replace(" ", "-", $prod_name)) == strtolower(str_replace(" ", "-", $old_prod_name))) {
    if(file_exists('../'.$category.'/'.$subcategory.'/'.$subsubcategory.'/'.strtolower(str_replace(" ", "-", $old_prod_name)).'.php')){
$sql ="UPDATE  product  SET
			feacture_product='$featured_product',best_product='$best_products',category_id='$cat_id',sub_category_id='$subcat_id', sub_sub_cat_id='$subsub_catid',prod_code='$prod_code',prod_name='$product_name',prod_test_type='$prod_test_type',prod_brand='$prod_brand',prod_desp='$prod_desp',features='$howto_use' WHERE id='$id'"; 
			$res=mysqli_query($conn,$sql) or die(mysqli_error());
			if($res)
			{
			$sqlg = "SELECT * from product where id = $id";
			  $resultg = mysqli_query($conn,$sqlg) or die(mysqli_error());
			  $resg = mysqli_fetch_object($resultg);
			  
			  if($_FILES["prod_img1"]["name"] != ""){
				$oname=$_FILES["prod_img1"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img1"]["tmp_name"];
				$path = "product/".$resg->id.'1'.'.'.$extension;
				$upath = "product/".$resg->prod_img1;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image1 = $resg->id.'1'.'.'.$extension;
				} else {
				  $image1 = $resg->prod_img1;
				}

			if($_FILES["prod_img2"]["name"] != ""){
				$oname=$_FILES["prod_img2"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img2"]["tmp_name"];
				$path = "product/".$resg->id.'2'.'.'.$extension;
				$upath = "product/".$resg->prod_img2;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image2 = $resg->id.'2'.'.'.$extension;
				} else {
				  $image2 = $resg->prod_img2;
				}

			if($_FILES["prod_img3"]["name"] != ""){
				$oname=$_FILES["prod_img3"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img3"]["tmp_name"];
				$path = "product/".$resg->id.'3'.'.'.$extension;
				$upath = "product/".$resg->prod_img3;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image3 = $resg->id.'3'.'.'.$extension;
				} else {
				  $image3 = $resg->prod_img3;
				}

			if($_FILES["prod_img4"]["name"] != ""){
				$oname=$_FILES["prod_img4"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img4"]["tmp_name"];
				$path = "product/".$resg->id.'4'.'.'.$extension;
				$upath = "product/".$resg->prod_img4;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image4 = $resg->id.'4'.'.'.$extension;
				} else {
				  $image4 = $resg->prod_img4;
				}

			if($_FILES["prod_img5"]["name"] != ""){
				$oname=$_FILES["prod_img5"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img5"]["tmp_name"];
				$path = "product/".$resg->id.'5'.'.'.$extension;
				$upath = "product/".$resg->prod_img5;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image5 = $resg->id.'5'.'.'.$extension;
				} else {
				  $image5 = $resg->prod_img5;
				} 


			$sqlup = "UPDATE product SET  prod_img1 =  '$image1',prod_img2 =  '$image2',prod_img3 =  '$image3',prod_img4 =  '$image4',prod_img5 =  '$image5' WHERE id = $resg->id";
				$resultup = mysqli_query($conn,$sqlup) or die(mysqli_error());
				if($resultup)
				{
			   echo "<script>document.location.href='products.php'</script>";
			   }		
			}
      }  else{
		if(copy('../product-detail.php', '../'.$category.'/'.$subcategory.'/'.$subsubcategory.'/'.strtolower(str_replace(" ", "-", $old_prod_name)).'.php')) {
				$sql ="UPDATE  product  SET
			feacture_product='$featured_product',best_product='$best_products',category_id='$cat_id',sub_category_id='$subcat_id', sub_sub_cat_id='$subsub_catid',prod_code='$prod_code',prod_name='$product_name',prod_test_type='$prod_test_type',prod_brand='$prod_brand',prod_desp='$prod_desp',features='$howto_use' WHERE id='$id'"; 
			$res=mysqli_query($conn,$sql) or die(mysqli_error());
			if($res)
			{
			$sqlg = "SELECT * from product where id = $id";
			  $resultg = mysqli_query($conn,$sqlg) or die(mysqli_error());
			  $resg = mysqli_fetch_object($resultg);
			  
			  if($_FILES["prod_img1"]["name"] != ""){
				$oname=$_FILES["prod_img1"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img1"]["tmp_name"];
				$path = "product/".$resg->id.'1'.'.'.$extension;
				$upath = "product/".$resg->prod_img1;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image1 = $resg->id.'1'.'.'.$extension;
				} else {
				  $image1 = $resg->prod_img1;
				}

			if($_FILES["prod_img2"]["name"] != ""){
				$oname=$_FILES["prod_img2"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img2"]["tmp_name"];
				$path = "product/".$resg->id.'2'.'.'.$extension;
				$upath = "product/".$resg->prod_img2;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image2 = $resg->id.'2'.'.'.$extension;
				} else {
				  $image2 = $resg->prod_img2;
				}

			if($_FILES["prod_img3"]["name"] != ""){
				$oname=$_FILES["prod_img3"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img3"]["tmp_name"];
				$path = "product/".$resg->id.'3'.'.'.$extension;
				$upath = "product/".$resg->prod_img3;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image3 = $resg->id.'3'.'.'.$extension;
				} else {
				  $image3 = $resg->prod_img3;
				}

			if($_FILES["prod_img4"]["name"] != ""){
				$oname=$_FILES["prod_img4"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img4"]["tmp_name"];
				$path = "product/".$resg->id.'4'.'.'.$extension;
				$upath = "product/".$resg->prod_img4;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image4 = $resg->id.'4'.'.'.$extension;
				} else {
				  $image4 = $resg->prod_img4;
				}

			if($_FILES["prod_img5"]["name"] != ""){
				$oname=$_FILES["prod_img5"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img5"]["tmp_name"];
				$path = "product/".$resg->id.'5'.'.'.$extension;
				$upath = "product/".$resg->prod_img5;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image5 = $resg->id.'5'.'.'.$extension;
				} else {
				  $image5 = $resg->prod_img5;
				} 


			$sqlup = "UPDATE product SET  prod_img1 =  '$image1',prod_img2 =  '$image2',prod_img3 =  '$image3',prod_img4 =  '$image4',prod_img5 =  '$image5' WHERE id = $resg->id";
				$resultup = mysqli_query($conn,$sqlup) or die(mysqli_error());
				if($resultup)
				{
			   echo "<script>document.location.href='products.php'</script>";
			   }		
			}

				}
			}
		  }
		}else{
			if(file_exists('../'.$category.'/'.$subcategory.'/'.$subsubcategory.'/'.strtolower(str_replace(" ", "-", $old_prod_name)).'.php')){
               	if(rename("../$category/$subcategory/$subsubcategory/".strtolower(str_replace(" ", "-", $old_prod_name)).".php", "../$category/$subcategory/$subsubcategory/".strtolower(str_replace(" ", "-", $prod_name)).".php")){
            $sql ="UPDATE  product  SET
			feacture_product='$featured_product',best_product='$best_products',category_id='$cat_id',sub_category_id='$subcat_id', sub_sub_cat_id='$subsub_catid',prod_code='$prod_code',prod_name='$product_name',prod_test_type='$prod_test_type',prod_brand='$prod_brand',prod_desp='$prod_desp',features='$howto_use' WHERE id='$id'"; 
			$res=mysqli_query($conn,$sql) or die(mysqli_error());
			if($res)
			{
			$sqlg = "SELECT * from product where id = $id";
			  $resultg = mysqli_query($conn,$sqlg) or die(mysqli_error());
			  $resg = mysqli_fetch_object($resultg);
			  
			  if($_FILES["prod_img1"]["name"] != ""){
				$oname=$_FILES["prod_img1"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img1"]["tmp_name"];
				$path = "product/".$resg->id.'1'.'.'.$extension;
				$upath = "product/".$resg->prod_img1;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image1 = $resg->id.'1'.'.'.$extension;
				} else {
				  $image1 = $resg->prod_img1;
				}

			if($_FILES["prod_img2"]["name"] != ""){
				$oname=$_FILES["prod_img2"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img2"]["tmp_name"];
				$path = "product/".$resg->id.'2'.'.'.$extension;
				$upath = "product/".$resg->prod_img2;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image2 = $resg->id.'2'.'.'.$extension;
				} else {
				  $image2 = $resg->prod_img2;
				}

			if($_FILES["prod_img3"]["name"] != ""){
				$oname=$_FILES["prod_img3"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img3"]["tmp_name"];
				$path = "product/".$resg->id.'3'.'.'.$extension;
				$upath = "product/".$resg->prod_img3;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image3 = $resg->id.'3'.'.'.$extension;
				} else {
				  $image3 = $resg->prod_img3;
				}

			if($_FILES["prod_img4"]["name"] != ""){
				$oname=$_FILES["prod_img4"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img4"]["tmp_name"];
				$path = "product/".$resg->id.'4'.'.'.$extension;
				$upath = "product/".$resg->prod_img4;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image4 = $resg->id.'4'.'.'.$extension;
				} else {
				  $image4 = $resg->prod_img4;
				}

			if($_FILES["prod_img5"]["name"] != ""){
				$oname=$_FILES["prod_img5"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img5"]["tmp_name"];
				$path = "product/".$resg->id.'5'.'.'.$extension;
				$upath = "product/".$resg->prod_img5;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image5 = $resg->id.'5'.'.'.$extension;
				} else {
				  $image5 = $resg->prod_img5;
				} 


			$sqlup = "UPDATE product SET  prod_img1 =  '$image1',prod_img2 =  '$image2',prod_img3 =  '$image3',prod_img4 =  '$image4',prod_img5 =  '$image5' WHERE id = $resg->id";
				$resultup = mysqli_query($conn,$sqlup) or die(mysqli_error());
				if($resultup)
				{
			   echo "<script>document.location.href='products.php'</script>";
			   }		
			}
   }
  } else{   if(copy('../product-detail.php', '../'.$category.'/'.$subcategory.'/'.$subsubcategory.'/'.strtolower(str_replace(" ", "-", $prod_name)).'.php')) {
			$prod_name=mysqli_real_escape_string($conn,$_POST['prod_name']);
$sql ="UPDATE  product  SET
			feacture_product='$featured_product',best_product='$best_products',category_id='$cat_id',sub_category_id='$subcat_id', sub_sub_cat_id='$subsub_catid',prod_code='$prod_code',prod_name='$product_name',prod_test_type='$prod_test_type',prod_brand='$prod_brand',prod_desp='$prod_desp',features='$howto_use' WHERE id='$id'"; 
			$res=mysqli_query($conn,$sql) or die(mysqli_error());
			if($res)
			{
			$sqlg = "SELECT * from product where id = $id";
			  $resultg = mysqli_query($conn,$sqlg) or die(mysqli_error());
			  $resg = mysqli_fetch_object($resultg);
			  
			  if($_FILES["prod_img1"]["name"] != ""){
				$oname=$_FILES["prod_img1"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img1"]["tmp_name"];
				$path = "product/".$resg->id.'1'.'.'.$extension;
				$upath = "product/".$resg->prod_img1;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image1 = $resg->id.'1'.'.'.$extension;
				} else {
				  $image1 = $resg->prod_img1;
				}

			if($_FILES["prod_img2"]["name"] != ""){
				$oname=$_FILES["prod_img2"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img2"]["tmp_name"];
				$path = "product/".$resg->id.'2'.'.'.$extension;
				$upath = "product/".$resg->prod_img2;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image2 = $resg->id.'2'.'.'.$extension;
				} else {
				  $image2 = $resg->prod_img2;
				}

			if($_FILES["prod_img3"]["name"] != ""){
				$oname=$_FILES["prod_img3"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img3"]["tmp_name"];
				$path = "product/".$resg->id.'3'.'.'.$extension;
				$upath = "product/".$resg->prod_img3;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image3 = $resg->id.'3'.'.'.$extension;
				} else {
				  $image3 = $resg->prod_img3;
				}

			if($_FILES["prod_img4"]["name"] != ""){
				$oname=$_FILES["prod_img4"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img4"]["tmp_name"];
				$path = "product/".$resg->id.'4'.'.'.$extension;
				$upath = "product/".$resg->prod_img4;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image4 = $resg->id.'4'.'.'.$extension;
				} else {
				  $image4 = $resg->prod_img4;
				}

			if($_FILES["prod_img5"]["name"] != ""){
				$oname=$_FILES["prod_img5"]["name"];
				$pos = strrpos($oname, ".");
				$extension=substr($oname,$pos+1);
				$tn = $_FILES["prod_img5"]["tmp_name"];
				$path = "product/".$resg->id.'5'.'.'.$extension;
				$upath = "product/".$resg->prod_img5;
				unlink($upath);
				 move_uploaded_file($tn,$path);
				 $image5 = $resg->id.'5'.'.'.$extension;
				} else {
				  $image5 = $resg->prod_img5;
				} 
			$sqlup = "UPDATE product SET  prod_img1 =  '$image1',prod_img2 =  '$image2',prod_img3 =  '$image3',prod_img4 =  '$image4',prod_img5 =  '$image5' WHERE id = $resg->id";
				$resultup = mysqli_query($conn,$sqlup) or die(mysqli_error());
				if($resultup)
				{
			    echo "<script>document.location.href='products.php'</script>";
			   }		
			}
	      }

        }
      }
  }

?>

<!DOCTYPE html>
<html lang="en-IN">

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">	
  <title>Orange Groceries</title>
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
	<?php include("includes/css.php")?>
</head>

<body class="hold-transition skin-blue sidebar-mini">
	<div class="wrapper">
		<?php include("includes/header.php")?>
		<?php include("includes/sidebar.php")?>
		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper">
			<!-- Content Header (Page header) -->
			<!-- Main content -->
			<section class="content">
				<div class="row">
					<div class="col-md-12">
						<div class="box box-danger">
							<div class="box-header">
								<h3 class="box-title">Edit Product Details</h3>
							</div>
							<div class="box-body">
								<form method="post" action="" enctype="multipart/form-data">
									<div class="form-group">
										<?php while($res= mysqli_fetch_array($result)){ ?>
										<div class="col-md-4">
										 <div class="checkbox">
											 <label class="">
											  <input name="featured_product" value="1" type="checkbox">
											Featured Product 
											</label>
										  </div>
									    </div> 
										<div class="col-md-4">
										 <div class="checkbox">
											 <label class="">
											  <input name="best_products" value="1" type="checkbox">
											 Best products
											</label>
										  </div>
									    </div> 	
										<div class="col-md-4">
											<label>Category:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<select name="category" id="cat_id" value="<?php echo $res['category_id']; ?>" class="form-control" >
												<option value="<?php echo $res['cid']; ?>"><?php echo $res['cat_name']; ?></option>
												 <?php
										            $sql2="SELECT * from category";
										            $exe2=mysqli_query($conn,$sql2);
										            while ($res2=mysqli_fetch_array($exe2))
										            {
										            ?>
										            <option value="<?php echo $res2['id']; ?>"><?php echo $res2['cat_name'];?></option>
										            <?php
										            }
										            ?>
											</select>
											</div>
										</div>
										<div class="col-md-4">
											<label>Sub-Category:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<select name="sub_category" id="sub_cat" value="<?php echo $res['sub_category_id']; ?>" class="form-control" >
												<option value="<?php echo $res['scat_id']; ?>"><?php echo $res['sub_category_name']; ?></option>
												</select>
											</div>
										</div>
										<div class="col-md-4">
											<label>Sub-Sub-Category:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<select name="sub_sub_category" id="subsub_cat" value="<?php echo $res['sub_sub_cat_name']; ?>" class="form-control" >
												<option value="<?php echo $res['sscate_id']; ?>"><?php echo $res['sub_sub_cat_name']; ?></option>
												</select>
											</div>
										</div>
										<div class="col-md-4">
											<label> Product Code:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<input type="text" name="prod_code" value="<?php echo $res['prod_code']; ?>" class="form-control" placeholder="Enter Product Code ">
											</div>
										</div>
										<div class="col-md-4">
											<label> Product Name:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<input type="text" class="form-control" name="prod_name" value="<?php echo $res['prod_name']; ?>" placeholder="Enter Product Name ">
												<input type="hidden" name="old_prod_name" value="<?php echo $res['prod_name']; ?>">
											</div>
										</div>
										<div class="col-md-4">
											<label> Product Taste Type:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<select name="prod_test_type" value="<?php echo $res['prod_test_type']; ?>" class="form-control">
													<option>Veg</option>
													<option>Non-Veg</option>
												</select>
											</div>
										</div>
										
										<div class="col-md-4">
											<label> Product Brand:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<input type="text" name="prod_brand" value="<?php echo $res['prod_brand']; ?>" class="form-control" placeholder="Enter Product Brand">
											</div>
										</div>
										<!-- <div class="col-md-12">
											<label> Note:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<textarea class="form-control" value="" name="note" rows="1" placeholder="Write Note"><?php echo $res['note']; ?></textarea>
											</div>
										</div> -->
										<div class="col-md-12">
											<label> Product Description:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<textarea class="form-control" name="prod_desp" rows="5" placeholder="Enter Product Description"><?php echo $res['prod_desp']; ?></textarea>
											</div>
										</div>
										<div class="col-md-12">
											<label>Product Features:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<textarea class="form-control" name="howto_use" rows="5" placeholder="Product Features"><?php echo $res['features']; ?></textarea>
											</div>
										</div>
										<div class="col-md-4">
											<label> Product Images 1:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<input type="File"  name="prod_img1" class="form-control">
												 <br/><img src="product/<?php echo $res['prod_img1'];?>" width="60px">
											</div>
										</div>
										<div class="col-md-4">
											<label> Product Images 2:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<input type="File" name="prod_img2" class="form-control">
												 <br/><img src="product/<?php echo $res['prod_img2'];?>" width="60px">
											</div>
										</div>
										<div class="col-md-4">
											<label> Product Images 3:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<input type="File" name="prod_img3" class="form-control">
												 <br/><img src="product/<?php echo $res['prod_img3'];?>" width="60px">
											</div>
										</div>
										<div class="col-md-4">
											<label> Product Images 4:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<input type="File" name="prod_img4" class="form-control">
												 <br/><img src="product/<?php echo $res['prod_img4'];?>" width="60px">
											</div>
										</div>
										<div class="col-md-4">
											<label> Product Images 5:</label>
											<div class="input-group">
												<div class="input-group-addon">
													<i class="fa fa-suitcase"></i>
												</div>
												<input type="File" name="prod_img5" class="form-control">
												 <br/><img src="product/<?php echo $res['prod_img5'];?>" width="60px">
											</div>
										</div>
									<?php } ?>
									</div>
									<div class="clearfix"></div>
									<div class="col-md-4 mt-20">
										<div class="form-group">
												<input type='hidden' name='id' value="<?php echo $_GET['id']?>" />
											<input type="submit" name="update" class="btn btn-success btn-md" value="Update">
										</div>
									</div>
								</form>
							</div>
							<!-- /.box-body -->
						</div>
					</div>
				</div>
			</section>
		</div>
		<?php include("includes/footer.php")?>
	</div>
	<?php include("includes/js.php")?>
<script type="text/javascript">
	$(document).ready(function(){
		    $('#cat_id').on('change', function(){
		        var cat_id = $(this).val();
		        if(cat_id){
		            $.ajax({
		                type:'POST',
		                url:'ajax_get_subsub_cat.php',
		                data:'cat_id='+cat_id,
		                success:function(html){
		                    $('#sub_cat').html(html);
		                   // console.log(html);
		                   // $('#city').html('<option value="">Select Division</option>'); 
		                }
		            }); 
		        }
		    });

		    	$('#sub_cat').on('change', function(){
		        var scat_id = $(this).val();
		        if(scat_id){
		            $.ajax({
		                type:'POST',
		                url:'ajax_get_subsub_cat.php',
		                data:'scat_id='+scat_id,
		                success:function(html){
		                    $('#subsub_cat').html(html);
		                }
		            }); 
		        }
		    });
        });
</script>
</body>
</html>