GIF89a php
Current File : /home/viralhoga/public_html/adminpanel/productedit.php
<?php
//error_reporting(0);
include("include/header.php");
include('include/admin-main.php');
$select_obj= new admin();
$result=$select_obj->select_myproduct("product");
//select menu name
$menu_details=$select_obj->select_myobjData("menu");

	if(isset($_POST['UpdateData'])){   
		$bindingtype=$_POST['bindingtype'];
	    $menu_id = @mysqli_real_escape_string($con,$_REQUEST['menu_id']);
		$cat_id = @mysqli_real_escape_string($con,$_REQUEST['cat_id']);	
		$subcat_id = @mysqli_real_escape_string($con,$_REQUEST['subcat_id']);		
		$pro_name = @mysqli_real_escape_string($con,$_REQUEST['name']);
		$price = @mysqli_real_escape_string($con,$_REQUEST['price']);	
		$oldprice = @mysqli_real_escape_string($con,$_REQUEST['oldprice']);	
		$oldprc = @mysqli_real_escape_string($con,$_REQUEST['oldprc']);	
	    $brand = @mysqli_real_escape_string($con,$_REQUEST['brand']);
		$Pro_code = @mysqli_real_escape_string($con,$_REQUEST['Pro_code']);
		$pro_type = @mysqli_real_escape_string($con,$_REQUEST['pro_type']);
		$pro_size = @mysqli_real_escape_string($con,$_REQUEST['pro_size']);
		$available_Color = @mysqli_real_escape_string($con,$_REQUEST['available_Color']);
		$stock = @mysqli_real_escape_string($con,$_REQUEST['stock']);
		
		
		$description = @mysqli_real_escape_string($con,$_REQUEST['description']);
        $id=$_REQUEST['id'];
		/*--------------this code for uploading image one by one at the time of edit--------*/
        $type = @mysqli_real_escape_string($con,$_REQUEST['type']);
		$filename_arr=array();
		$edit_imgup=null;
	if(is_uploaded_file($_FILES['edit_image']['tmp_name']))
			{
			$ext=explode(".",$_FILES['edit_image']['name']);
			$size=sizeof($ext);
			$r = md5(uniqid(mt_rand(),true));
			$img2 = $r.".".$ext[$size-1];
			
			$edit_imgup=move_uploaded_file($_FILES['edit_image']['tmp_name'], "img/".$img2);
			$filenamea = $img2;
           array_push($filename_arr,$filenamea);			
			}
			$result=mysqli_query($con,"select img from  product where id='$id'") or die(mysqli_error());
			$img=mysqli_fetch_array($result);
			$img_arr=$img['img'];
			$img_result=json_decode($img_arr);
			//array_push($newarr,$img_result);
			if($img_result=="")
			{
			$new5=array_values($filename_arr);
			}
			else
			{
		$new4=array_merge($filename_arr,$img_result);
		$new5=array_values($new4);
		//print_r($new5);
		echo "<br>";
		}
		$property_image_name=json_encode($new5);
		//print_r($property_image_name);


/*--------------this code for uploading image one by one at the time of edit--------*/

   @$sql3="Update product set menu_id='$menu_id',cat_id='$cat_id',subcat_id='$subcat_id',name='$pro_name',price='$price',brand='$brand',Pro_code='$Pro_code',pro_type='$pro_type',pro_size='$pro_size',available_Color='$available_Color',stock='$stock',description='$description',img='$property_image_name',oldprice='$oldprice',oldprc='$oldprc',videoType='$_POST[videoType]',videoUrl='$_REQUEST[videoUrl]' where  id=".$_REQUEST['id'];
		
		  $res=mysqli_query($con,$sql3)or mysqli_error();
		  ?>
<script type="text/javascript">
		window.location="productdetails.php";
		</script>
<?php
	
	}
	
	// delete from the table
	$id1 = $_REQUEST['id'];
	if(isset($_GET['delete']))
	{
	$id=$_GET['id'];
	$delete=$_GET['delete'];
	$result=mysqli_query($con,"select img from  product where id='$id'");
	$img=mysqli_fetch_array($result);
	$img_arr=$img['img'];
	$propertyx_image=json_decode($img_arr);
	$new2=array_diff($propertyx_image,array($delete));
	$new3=array_values($new2);
	$new_arr_data=json_encode($new3);
	$updt=mysqli_query($con,"update  product set img='$new_arr_data' where id='$id'");
	unlink("../image/product/".$delete);
    if($updt)
	{
	echo "<script>alert('product_image deleted Successfully')</script>";
	echo "<script>window.location='$_SERVER[HTTP_REFERER]'</script>";
	}
	}	

$dt = @mysqli_fetch_array(mysqli_query($con,"select * from product where  id=".$_REQUEST['id']));
//set type
$song_type_details=$select_obj->select_objData("pin_code","order by position");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Mosaddek">
<meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
<link rel="shortcut icon" href="img/favicon.png">
<title><?php include("include/title.php")?> Product Details</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-reset.css" rel="stylesheet">
<!--external css-->
<link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
<link href="assets/advanced-datatable/media/css/demo_page.css" rel="stylesheet" />
<link href="assets/advanced-datatable/media/css/demo_table.css" rel="stylesheet" />
<!-- Custom styles for this template -->
<link href="css/style.css" rel="stylesheet">
<link href="css/style-responsive.css" rel="stylesheet" />
<script type="text/javascript" src="css1/js/ckeditor/ckeditor.js"></script>
</head>
<body>
<?php  include 'popup.php' ?>
<!--header end-->
<!--sidebar start-->
<?php  include 'menu.php' ?>
<!--sidebar end-->
<!--main content start-->
<section id="main-content">
  <section class="wrapper">
    <!-- page start-->
    <div class="row">
      <div class="col-lg-12">
        <section class="panel">
          <header class="panel-heading">
            <center>
              <b>Update Product Details</b>
            </center>
          </header>
          <form action="" method="post" enctype="multipart/form-data">
            <header class="panel-heading">
              <?php if($dt['img'])
				{ 
				$dcd_img=json_decode($dt['img']);
				 
				}
				?>
							  <?php
				if(@$dcd_img=="")
				{}
				else
				{
				foreach($dcd_img as $v)
				{
				?>
							  <img src='img/<?php echo $v;?>' height="40" width="50"> <a href="productedit.php?id=<?php echo $dt['id'];?>&action=edit&delete=<?php echo $v;?>">Delete</a>
							  <?php
				}
				}
				?>
              <input type="file" name="edit_image" class="form-control">
              <br>
              Category Name
              <select name="menu_id" class="form-control" onChange="showUser123(this.value)">
                <?php $sel_menu=mysqli_fetch_array(mysqli_query($con,"select menu from menu where menu_id='$dt[menu_id]'"))?>
                <option value="<?php echo $dt['menu_id']?>" selected="selected"><?php echo $sel_menu['menu']?></option>
                <?php
	            while($row = mysqli_fetch_array($menu_details)){
	            if($row['menu']=='Exclusive' || $row['menu']=='Non-Exclusive'){
	            ?>
                <option value="<?php echo $row['menu_id'];?>"><?php echo $row['menu'];?></option>
                <?php
	              }
	            }
	             ?>
              </select>
              <br>
              Is Video?
			  <select class="form-control" name="videoType" required="">
				<option value="">Select</option>
				<option value="Yes" <?php if($dt['videoType']=="Yes")echo "selected";?>>Yes</option>
				<option value="No" <?php if($dt['videoType']=="No")echo "selected";?>>No</option>
			  </select>
			  <br>
              Video URL
			  <input type="text" class="form-control" name="videoUrl" value="<?php echo $dt['videoUrl']?>" required="">	
			  <br>
			  <span style="display:none">
              Sub Category
              <select name="cat_id" id="txtHint" class="form-control" onChange="showUser1234(this.value)">
                <?php $sel_cat=mysqli_fetch_array(mysqli_query($con,"select category_name from categories where cat_id='$dt[cat_id]'"))?>
                <option value="<?php echo $dt['cat_id'];?>" selected="selected"><?php echo $sel_cat['category_name'];?></option>
              </select>
              <br>
              SubToSub Category
              <select name="subcat_id" id="txtHint1" class="form-control">
                <?php $sel_subcat=mysqli_fetch_array(mysqli_query($con,"select subcat_name from subcategory where subcat_id='$dt[subcat_id]'"))?>
                <option value="<?php echo $dt['subcat_id'];?>" selected="selected"><?php echo $sel_subcat['subcat_name'];?></option>
              </select>
              <br>
			  </span>
              Song Name
              <input type="text" name="brand"  placeholder="Song Name" value="<?php echo $dt['brand'];?>" class="form-control">
              <br>
			  Singer Name
              <input type="text" placeholder="Name"  class="form-control" name="name" value="<?php echo $dt['name'];?>">
              <br>
              Start Price
              <input type="text" name="price" placeholder="Price" value="<?php echo $dt['price'];?>" class="form-control">
              <br>
			  Old Price
              <input type="text" name="oldprc"  placeholder="Old Price" value="<?php echo $dt['oldprc'];?>" class="form-control">
			  <br>
              Tag Name
              <input type="text" name="oldprice" placeholder="Old Price" value="<?php echo $dt['oldprice'];?>" class="form-control">
              <small>Different Tag name seperated with comma</small> <br>
			  <br>
              Song Type
              <select name="pro_type" class="form-control">
                <option value="<?php echo $dt['pro_type'];?>" selected="selected"><?php echo $dt['pro_type'];?></option>
                <?php while($songType = mysqli_fetch_array($song_type_details)){?>
				 <option><?php echo $songType['pin']?></option>
				<?php }?>
              </select>
              <br>
              Buy 1 Price/Discount
              <input type="text" name="Pro_code"  placeholder="Discount" value="<?php echo $dt['Pro_code'];?>" class="form-control">
			  <small>Different Buy Discount seperated with comma</small>
              <br>
              Add On
			  <select class="form-control" name="pro_size" required="">
				<option value="">Select</option>
				<option value="Yes" <?php if($dt['pro_size']=="Yes")echo "selected";?>>Enable</option>
				<option value="No" <?php if($dt['pro_size']=="No")echo "selected";?>>Disable</option>
			  </select>
              <br>
              Deliver Video Within
              <input type="text" name="stock"  placeholder="Deliver Video Within" value="<?php echo $dt['stock'];?>" class="form-control">
			  <br>
			  <span style="display:none">
              Available Color
              <input type="text" name="available_Color"  placeholder="Available Color( Hint:- red,black,blue )" value="<?php echo $dt['available_Color'];?>" class="form-control">
              <br>
			  </span>
              Description
              <textarea name="description" row="6" id="editor1" class="form-control"><?php echo $dt['description'];?></textarea>
              <br>
              <center>
                <input type="submit" class="btn btn-shadow btn-danger" value="Update" name="UpdateData">
              </center>
            </header>
          </form>
        </section>
      </div>
    </div>
    <!-- page end-->
  </section>
</section>
<!--main content end-->
</section>
<script type="text/javascript" src="scripts/jquery.sceditor.bbcode.min.js"></script>
<script type="text/javascript" src="scripts/jquery.sceditor.js"></script>
<!--CKEDITOR-->
<script src="https://use.fontawesome.com/32f073b29a.js"></script>
<script src="ckeditor/ckeditor.js"></script>
<script src="ckeditor/js/sample.js"></script>		
<script>
    CKEDITOR.replace('editor1', {
      width: '100%'
    });
</script>  
</body>
</html>