<html>
	<head>
	
		<title>Admin panel</title>
			
		<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
		<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
		<link rel="stylesheet" href="../css/styleAdmin.css" type="text/css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=PT+Sans">
		
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" ></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" ></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>

	</head>
	<body>
		<div id="menu-bar">
			<div id="menu" onclick="onClickMenu()">
				<div id="bar1" class="bar"></div>
				<div id="bar2" class="bar"></div>
				<div id="bar3" class="bar"></div>
			</div>
			<ul class="nav" id="nav">
				<li><a href="index.php">Home</a></li>
				<li><a href="category.php">Category</a></li>
				<li><a href="author.php">Author</a></li>
				<li><a href="books.php">Books</a></li>
				<li><a href="bookingOrders.php">Books Orders </a></li>
				<li><a href="orderstatus.php">Order Status </a></li>
			</ul>
		</div>
		<div class="menu-bg" id="menu-bg"></div>
		<script>
 		function onClickMenu(){
		document.getElementById("menu").classList.toggle("change");
		document.getElementById("nav").classList.toggle("change");
	
		document.getElementById("menu-bg").classList.toggle("change-bg");
}
		</script>
		<div class="">
		<h1 class="hed">Admin Panel<img src="../pic/logo1.png" class="log"><h1></div>
		<hr>
		
<!------------------------------------------------------------------------------------------->
<div class="container">
<div class="text-center">
        <h2 style="margin-top: 0px; padding-top: 0; padding-left: 5px;color:white; ">Update a Book</h2>
    </div><hr color="white">
	
	 <?php
    try {
        $db = new PDO('mysql:host=localhost;dbname=gdhhsxmy_monsoonvibespublica;charset=utf8', 'gdhhsxmy_monsoonvibespublica', 'monsoonvibespublica');
    } catch (Exception $e) {
        echo 'Error has Occured';
    }

	 if (isset($_POST['edit_btn'])) {
	     $id = $_POST['edit_id'];
	 }
	 ?>
	  
   
<?php
	 try {
	     $db = new PDO('mysql:host=localhost;dbname=gdhhsxmy_monsoonvibespublica;charset=utf8', 'gdhhsxmy_monsoonvibespublica', 'monsoonvibespublica');
	 } catch (Exception $e) {
	     echo 'Error has Occured';
	 }


	 $stmt = $db->query("select * from product where id=$id");
	 while ($row = $stmt->fetch()) {
	     ?>

<form action="Template/BookupdateQuery.php" method="post" enctype="multipart/form-data">
<div class="form-row" >
  <div class="form-group col-md-2">
      <label>Product Id</label>
      <input type="text" class="form-control" value="<?php echo $row['id'] . ' ' ?>" name="id" readonly />
    </div>
    <div class="form-group col-md-6">
      <label >Title</label>
      <input type="text" class="form-control" value="<?php echo $row['title'] . ' ' ?>" name="title" required />
    </div>
    <div class="form-group col-md-4">
      <label >Price</label>
      <input type="number" class="form-control" value="<?php echo $row['price'] ?>" name="price" min="0" required />
    </div>

  </div>
   <div class="form-group">
    <label >Description</label>
    <textarea class="form-control"  rows="10" maxlength="5000" name="description" required /><?php echo $row['description'] ?></textarea>
  </div>
  
  <div class="form-row" >
  <div class="form-group col-md-6">
      <label >Category</label>
     <select class="form-control" name="catid" id="catid"  required />
       
            <?php
	               $stmt = $db->query('select * from category');

	     while ($row1 = $stmt->fetch()) {
	         ?>
                               
                <option value="<?php echo $row1['id']; ?>"<?php if ($row1['id'] == $row['catid']) {
                    echo 'selected' ;
                } ?> style="color:black;"><?php echo $row1['title']; ?> </option>
                
            <?php
	     }

	     ?>
        </select>
    </div>
    
     <div class="form-group col-md-6">
      <label >Author</label>
     <select class="form-control" name="authorid" id="authorid" required />
      
            <?php
	      $stmt = $db->query('select * from author');

	     while ($row2 = $stmt->fetch()) {
	         ?>
                
               
                
                <option value="<?php echo $row2['id']; ?>"<?php if ($row2['id'] == $row['authorid']) {
                    echo 'selected' ;
                } ?> style="color:black;"><?php echo $row2['title']; ?> </option>
                
            <?php
	     }

	     ?>
        </select>
    </div>
    
    </div>
    
  <div class="form-group">
      <label >Publishing Date</label>&nbsp;<span><font size="4" style="color:red;">*</font></span>
      <input type="date" class="form-control" name="publishing_date" value="<?php echo $row['publishing_date'] ?>" required />
    </div>
  
  <div class="form-group">
    <label >Edition</label>
    <input type="text" class="form-control" value="<?php echo $row['edition'] . ' ' ?>" name="edition" required />
  </div>
  
  <div class="form-group">
    <label >Number of Pages</label>
    <input type="text" class="form-control" value="<?php echo $row['no_of_pages'] . ' ' ?>" name="no_of_pages" required />
  </div>
  
   <div class="form-group">
        <label >Language</label>&nbsp;<span><font size="4" style="color:red;">*</font></span>
     <select class="form-control" name="language"  required />
      <option value="" >---Select---</option>
 <option name="language" style="color:black;" <?php if ($row['language'] == 'Malayalam') {
     echo 'selected="selected"';
 }?>>Malayalam</option>
   <option name="language" style="color:black;"<?php if ($row['language'] == 'English') {
       echo 'selected="selected"';
   }?>>English</option>
   <option name="language" style="color:black;"<?php if ($row['language'] == 'Hindi') {
       echo 'selected="selected"';
   }?>>Hindi</option>
   <option name="language" style="color:black;" <?php if ($row['language'] == 'Tamil') {
       echo 'selected="selected"';
   }?>>Tamil</option>
  </select>
   </div>
  
  <div class="form-group">
    <label >Old Price</label>
    <input type="text" class="form-control" value="<?php echo $row['old_price'] . ' ' ?>" name="old_price" required />
  </div>
  
    <div class="form-row" >
  <div class="form-group col-md-4">
    <label >Image</label>&nbsp;<span><font size="4" </font></span>
 <p>upload Photo:&nbsp;&nbsp;<input type="file" name="photo" value=""  />

</div>
</div>
  
  <div class="form-row" >
  <div class="form-group col-md-4">
      <label >Display</label>
     <select class="form-control" name="Display"  required />
  
  
    <option name="Display" style="color:black;" <?php if ($row['display'] == 'no') {
        echo 'selected="selected"';
    }?>>No</option>
    
      <option name="Display" style="color:black;" <?php if ($row['display'] == 'yes') {
          echo 'selected="selected"';
      }?>>Yes</option>
  </select>
    </div>
    
<div class="form-group col-md-4">
      <label >Paid Delivery</label>
     <select class="form-control" name="paid_delivery"  required />
  
  <option name="paid_delivery" style="color:black;" <?php if ($row['paid_delivery'] == 'no') {
      echo 'selected="selected"';
  }?>>No</option>
    
      <option name="paid_delivery" style="color:black;" <?php if ($row['paid_delivery'] == 'yes') {
          echo 'selected="selected"';
      }?>>Yes</option>
       
  </select>
    </div>
    
    
    <div class="form-group col-md-4">
      <label >Featured Product</label>
     <select class="form-control" name="featured_product"  required />
  
  
    <option name="featured_product" style="color:black;" <?php if ($row['featured_product'] == 'no') {
        echo 'selected="selected"';
    }?>>No</option>
    
      <option name="featured_product" style="color:black;" <?php if ($row['featured_product'] == 'yes') {
          echo 'selected="selected"';
      }?>>Yes</option>
  </select>
    </div>
    
    
     <div class="form-group col-md-4">
      <label >upcoming Book</label>
     <select class="form-control" name="upcoming"  required />
  
  
    <option name="upcoming" style="color:black;" <?php if ($row['upcoming'] == 'no') {
        echo 'selected="selected"';
    }?>>No</option>
    
      <option name="upcoming" style="color:black;" <?php if ($row['upcoming'] == 'yes') {
          echo 'selected="selected"';
      }?>>Yes</option>
  </select>
    </div>
    
    
    </div>
    
<button type="submit" name="submit" value="submit" class="btn btn-primary"/>Update</button>&nbsp;
<a href="books.php " class="button" style="color:white;">Cancel</a>
  </form>
  
  <?php
	 }
	 ?>


	
	</div>
	</body>
</html>	