<div class="col-md-12"> <?php if(isset($_POST['add'])) { $description = mysqli_real_escape_string($cn,$_POST['description']); $date = date('Y-m-d'); $name = $_POST['name']; $designation = $_POST['designation']; $image = $_FILES['image']['name']; move_uploaded_file ($_FILES['image']['tmp_name'],'../testimonial/'.$image); $sqlSubject=mysqli_query ($cn, "insert into `tbl_testimonial` set description='$description',date='$date',name='$name',designation='$designation',image='$image'"); if ($sqlSubject){ echo '<div class="alert alert-success"><strong>Success!</strong> Testimonial Page Added Successfully.</div>'; } else { echo '<div class="alert alert-danger"><strong>Danger!</strong> Testimonial Page Not Added.</div>'; } } if(isset($_POST['edit'])) { $id = $_POST['edit_id']; $description = mysqli_real_escape_string($cn,$_POST['description']); $date = date('Y-m-d'); $name = $_POST['name']; $designation = $_POST['designation']; $image = $_FILES['image']['name']; $sql = mysqli_query($cn, "select * from tbl_testimonial where id='$id'"); $sqlData = mysqli_fetch_array($sql); if(!empty($image)) { move_uploaded_file($_FILES['image']['tmp_name'],'../testimonial/'.$image); } else { $image = $sqlData['image']; } $sqlSubject = mysqli_query ($cn,"update tbl_testimonial SET description='$description',date='$date',name='$name',designation='$designation', image='$image' where `id`='$id'"); if($sqlSubject) { echo '<div class="alert alert-success"><strong>Success!</strong> Testimonial Page Update Successfully.</div>'; } else { echo '<div class="alert alert-success"><strong>Warrning!</strong> Not Updated try again.</div>'; } } if(isset($_GET['edit_id'])) { $id = $_GET['edit_id']; $sql = mysqli_query($cn, "select * from tbl_testimonial where id='$id'"); $sqlData = mysqli_fetch_array ($sql); } if(isset($_GET['delete_id'])) { $id = $_GET['delete_id']; $sql = mysqli_query($cn, "delete from tbl_testimonial where id='$id'"); if($sql) { echo '<div class="alert alert-success"><strong>Success!</strong> Testimonial Page Deleted Successfully.</div>'; } else { echo "error: " . $sql . "<br>" . mysqli_error($conn); } } ?> </div> <div class="card"> <div class="card-body"> <h4 class="card-title">Testimonials</h4> <form class="forms-sample" method="post" enctype="multipart/form-data"> <input type="hidden" value="<?php if(isset($_GET['edit_id'])) {echo $_GET['edit_id'];}?>" name="edit_id"> <div class="row"> <div class="col-md-12"> <div class="form-group"> <label for="exampleInputCity1">Testimonials Description</label> <textarea class="form-control" name="description" id="exampleInputCity1" placeholder="Testimonials Description" required><?php if(isset($_GET['edit_id'])) {echo $sqlData['description'];}?></textarea> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label for="exampleInputName1">Person Name</label> <input type="text" class="form-control" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['name'];}?>" name="name" id="exampleInputName1" placeholder="Person Name" autocomplete="off" required> </div> </div> <div class="col-md-4"> <div class="form-group"> <label for="exampleInputPassword4">Designation</label> <input type="text" class="form-control" name="designation" value="<?php if(isset($_GET['edit_id'])) {echo $sqlData['designation'];}?>" id="exampleInputPassword4" placeholder="Designation"> </div> </div> <div class="col-md-4"> Testimonial Image <input type="file" name="image" id="fileToUpload" <?php if(isset($_GET['edit_id'])){}else{?> required <?php }?>> <p style="color:red; ">Size must 235X54</p> <?php if(isset($_GET['edit_id'])) {?> <img src="../testimonial/<?php echo $sqlData['image'];?>" height="150" width="200"> <?php }?> </div> </div> <button type="submit" class="btn btn-success mr-2" name="<?php if(isset($_GET['edit_id'])) {echo "edit";}else{ echo "add";}?>">Submit</button> </form> </div> </div> <br><br> <div class="col-lg-12 grid-margin stretch-card"> <div class="card"> <div class="card-body"> <h4 class="card-title">Order List</h4> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>Sr. No.</th> <th>Image</th> <th>Person Name</th> <th>Designation</th> <th>Date</th> <th>Description</th> <th>Action</th> </tr> </thead> <tbody> <?php $i = 1; $sqlTestimonial = mysqli_query($cn, "select * from `tbl_testimonial`"); while($sqlTestimonialData = mysqli_fetch_array($sqlTestimonial)){ $sqlImage = mysqli_query($cn, "select * from `tbl_testimonial` where id='".$sqlTestimonialData['image']."'"); $sqlImageData = mysqli_fetch_array($sqlImage); ?> <tr> <td><?php echo $i++;?></td> <td><img src="../testimonial/<?php echo $sqlTestimonialData['image'];?>" height="150" width="200"/></td> <td><?php echo $sqlTestimonialData['name'];?></td> <td><?php echo $sqlTestimonialData['designation'];?></td> <td><?php echo date('d-m-Y',strtotime($sqlTestimonialData['date']));?></td> <td><?php echo $sqlTestimonialData['description'];?></td> <td>Publish | <a href="home.php?pages=testimonials&edit_id=<?php echo $sqlTestimonialData['id'];?>">Edit</a> | <a href="home.php?pages=testimonials&delete_id=<?php echo $sqlTestimonialData['id'];?>" onclick="return deleteConfirm();">Delete</a></td> </tr> <?php } ?> </tbody> </table> </div> </div> </div> </div>