<?php 
  session_start();
  include"inc/config.php";
   $errors = array(); // initialize variables
  $Id = ""; $Category_code="";    $Category_name= ""; $image= "";
  $Id = 0; 
  $update = false;

  if (isset($_GET['edit'])) { 
    $id = $_GET['edit'];
  $record = mysqli_query($db, "SELECT * FROM products WHERE id= $id ");


    if (count($record) == 1 ) {
    $n = mysqli_fetch_array($record);
     $id = $n['id'];  $category = $n['category'];  $name = $n['name'];  $size = $n['size'];  $price = $n['price']; 
      $price_1 = $n['price_1'];  $description = $n['description'];  $quantity = $n['quantity'];   $image = $n['image']; 
    }

  }

if (isset($_POST['update'])) {
$id = $_POST['id']; 

// $category = $_POST['category']; $p_name = $_POST['p_name']; $p_size = $_POST['p_size'];

 $price_1= $_POST['price_1'];


 // $image = $_FILES['image']['name'];
  
// $target = "../product-images/".basename($image);




$sql = "UPDATE products SET price_1 = '$price_1' WHERE id =$id";



 if ( ($db->query($sql) )) {
 echo "<script type= 'text/javascript'>alert('$name - offer  updated succesfully.');</script>";
 echo "<script type='text/javascript'>location.href = 'index.php?link=002products';</script>";
}
else{echo "<script type= 'text/javascript'>alert('Error!!! while [ $name ] updating.');</script>";}


}

?>


<!DOCTYPE>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
 body { font-family: helvetica, sans-serif; }
* {  box-sizing: border-box;}
body {  margin: 0;}

.top-aa{ padding:15px; text-align: left; width: 100%; font-size: x-small; color: #848482; margin-bottom: 1%;}

.wrapper{ background:whitesmoke;  width:100%; border: 0px solid #a1a1a1;  margin:auto; resize: none;     overflow:hidden; }

.column-a {  float: left;  width:18%;  padding: 0px; height: 90%; background:white ;border-top: 2px solid whitesmoke;  overflow-x: auto; scrollbar-width: thin; }

.column-b { float: left; width: 82%;  padding: 15px; overflow-x: auto; scrollbar-width: thin; height: 90%; }


/* Clear floats after the columns */
.row:after {
  content: "";
  display: table;
  clear: both;
}

@media screen and (max-width:600px) {
  .column-a { width: 100%; height: auto; }
  .column-b {  width: 100%; height:auto; } }

</style>
</head>
<body>


<div class="row">

<div class="wrapper">

  <nav> <?php include "header.php"; ?></nav>


  <div class="column-a"><?php include "menu.php"; ?>  </div>
  
  <div class="column-b">

<div class="top-aa">
<a href="index.php" style="color: black; text-decoration: none; font-weight: bold;"> Home </a>
<a href="index.php?link=002products" style="color: black; text-decoration: none; ">// Manage Products</a>
<a>// Udate Products Offers</a>
</div>

<?php include ("offers.php"); ?>

</div>





<?php include ("footer.php"); ?>
</div>
</div>
</body>
</html>
