<?php include("includes/db.php");?>

<?php 

if(isset($_POST['update'])){
    $id=$_POST['id'];
    $name = $_POST['name'];
    $amount =$_POST['amount'];
    $address    = $_POST['address'];
    $cond=$_POST['cond'];

$sql=mysqli_query($db,"UPDATE equipment SET name='$name',amount='$amount',address='$address',cond='$cond' WHERE id='$id'");

if($sql){

    echo" <script> alert(' Updated Successfully ');</script> ";
    // echo "<p id='display' style='background-color:green; font-weight:bold;color:white;box-shadow:0 0 5px #eee;padding:0px; border-radius:5px;font-size:16px;text-align:center;'>Updated Successful</p>";

}
    else{
        echo "<p id='display' style='background-color:red; font-weight:bold;color:white;box-shadow:0 0 5px #eee;padding:0px; border-radius:5px;font-size:16px;text-align:center;'>Something Went Wrong</p>";
    }
}

?>



<?php 

if(isset($_POST['delete'])){
    $id=$_POST['id'];
  $sql= mysqli_query($db,"DELETE FROM equipment WHERE id=$id");
if($sql){

    echo" <script> alert('Deleted Successfully ');</script> ";
    // echo "<p id='display' style='background-color:green; font-weight:bold;color:white;box-shadow:0 0 5px #eee;padding:0px; border-radius:5px;font-size:16px;text-align:center;'>Updated Successful</p>";

}
    else{
        echo "<p id='display' style='background-color:red; font-weight:bold;color:white;box-shadow:0 0 5px #eee;padding:0px; border-radius:5px;font-size:16px;text-align:center;'>Something Went Wrong</p>";
    }
}

?>



<?php
    $idn=$_GET['idn'];
$sql=mysqli_query($db, "SELECT * FROM authors WHERE idn='$idn' ");
$result=mysqli_fetch_assoc($sql);
$rows=mysqli_num_rows($sql);
if($rows ==0){
    header('location:index.php');
    exit();
}
$image=$result['image'];
$name=$result['name'];
$title=$result['btitle'];
$about=$result['aboutauthor'];
?>

<!-- header starts here -->
<?php include('includes/header.php') ?>
<!-- header ends here -->
<section class="hero-wrap hero-wrap-2" style="background-image: url('images/bg_5.jpg');" data-stellar-background-ratio="0.5">
      <div class="overlay"></div>
      <div class="container">
        <div class="row no-gutters slider-text align-items-center justify-content-center">
          <div class="col-md-9 ftco-animate mb-0 text-center">
          	<p class="breadcrumbs mb-0"><span class="mr-2"><a href="index.html">Home <i class="fa fa-chevron-right"></i></a></span> <span>Authors <i class="fa fa-chevron-right"></i></span></p>
            <h1 class="mb-0 bread">Author Blog </h1>
          </div>
        </div>
      </div>
    </section>
		
	<section class="ftco-section">
      <div class="container">
        <div class="row justify-content-center mb-5">
         
        </div>
        <div class="row d-flex">
          <div class="col-md-6 d-flex ftco-animate">
          	<div class="blog-entry justify-content-end">
              <div class="text text-center">
              	<img src="admin/authorimage/<?php echo $image?>" class="img-fluid" alt="">
	              <div class="meta text-center mb-2 d-flex align-items-center justify-content-center">
                	<div>
                		<span class="day"></span>
                		
                	</div>
                </div>
              </div>
            </div>
          </div>
       
		 </style>
          <div class="col-md-6 d-flex ftco-animate">
          	<div class="blog-entry justify-content-end">
              <h3 class="heading mb-3"><?php echo $name?></h3>
              <p><?php echo $title?></p>
				<p><?php echo $about?></p>

			</div>
            </div>
          </div>
        </div>
		
      </div>
    </section>	

 
<!-- footer starts here -->
<?php include('includes/footer.php') ?>
        <!-- footer ends here -->