<?php include('site-header.php'); ?>
<?php include('left-nevigation.php'); ?>
   <main id="playground">
 <?php include('site-top-header.php'); ?>

  




	
<?php
if(isset($_REQUEST['del']))
{
    $sql="delete from tbl_event where id=$_REQUEST[del]";  
                if(mysqli_query($link,$sql))
                 {
                   $img = "<p style='color:green;'>Delete successfully!!!!!</p>";
                 } 
}
?>

<?php
    extract($_POST);
    if(isset($Add))
    {

      $hid = $_POST['hid'];
       $cour = mysqli_query($link,"SELECT * FROM tbl_event  WHERE home_status='Home'");
      $row = mysqli_num_rows($cour);
      if($row>=1)
      {
        $msg = "<p style='color:red;'>Only one EVENTS  add home page!!!!!</p>";
      }
      else{
         if(mysqli_query($link,"UPDATE tbl_event  SET home_status='$Add' WHERE id='$hid'"))
          {
            $msg= "<p style='color:green;'>Category Add Home Page!!!!</p>";
          }
      }
    }
     if(isset($Remove))
     {
      $hid = $_POST['hid'];
      if(mysqli_query($link,"UPDATE tbl_event  SET home_status='$Remove' WHERE id='$hid'")){
        $msg= "<p style='color:red;'>EVENTS  Remove!!!!</p>";
      }
    }
    ?>



<section id="page-title" class="row">
      <div class="col-md-8">
        <h1>Upcoming Events List</h1>
        <p class="lead">View / Edit your Upcoming Events below</strong>.</p>
        <?=$msg;?>
        <p><a href="add-edit-event.php" class="btn btn-primary">Add New Upcoming Events </a></p> 
        
      </div>
 
      <div class="col-md-4">
       <!--  <ol class="breadcrumb pull-right no-margin-bottom">
          
          <li><a href="dashboard.php">Testimonial List</a></li>
          <li class="active">Update Testimonial</li><br><br>
         
        </ol> -->
        
      </div>
    </section>

<?php
$sql="select * from tbl_event ";
$data=mysqli_query($link,$sql);
?>	
    <!-- / PAGE TITLE -->
  
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-12">
          <section class="panel panel-primary">
            <header class="panel-heading">
              <h3 class="panel-title">Your Upcoming Events List</h3>
            </header>
            <table class="table table-hover table-responsive">
            <tbody>
              <tr>
                <th scope="row">S. No</th>
                <td>Title</td>
                <td>Location</td>
                <td>Add Home</td>
                <td>Date</td>
                <td>Image</td>
                
                <!-- 
                
                <td>Description</td> -->
                <td>Action</td>
              </tr>
              <tr>
              <?php
    			    $i=0;
    			    while($result=mysqli_fetch_array($data)){ 
      				$i++;
      				?>
                <th scope="row"><?php echo $i ?></th>
                <td><?php echo $result['name']; ?></td>
                <td><?php echo $result['A_name']; ?></td>
                <td>
                    <?php
                    if($result['home_status']=="Home")
                    {
                    ?>
                    <form method="post">
                      <input type="hidden" name="hid" value="<?=$result['id'];?>">
                      <input type="submit" name="Remove" value="Remove" class="btn btn-danger">
                    </form>
                    <?php
                    }
                    else
                    {
                    ?>
                    <form method="post">
                      <input type="hidden" name="hid" value="<?=$result['id'];?>">
                      <input type="submit" name="Add" value="Home" class="btn btn-success">
                    </form>
                    <?php
                    }
                    ?>
                  </td>
                 
                <td>   
                 <?php
                              $dateValue = $result['date'];
                              $dat = date('d', strtotime($dateValue));
                              $month = date('M', strtotime($dateValue));
                              echo $dat;
                              echo $month;   
                 ?>
                </td>
                
                <td><img src="../gallery-image/<?=$result['image'];?>" height="80" height="80"></td>
                <!-- <td> <?php echo $result['testi_desc']; ?> </td>
                 --><td><a href="add-edit-event.php?Updt_id=<?php echo $result['id'];?>" class="btn btn-primary" style="width:100px;">Edit</a><br>
                 <form method="post">
                <input type="hidden" name="del" value="<?php echo $result['id'];?>">
                  <button class="btn btn-danger" style="width:100px;">Delete</button> </td>
                </form> 
              </tr>
              <?php } ?>
           
            </tbody>
            </table>
          </section>
        </div>
      </div>
    </div>
    <!-- / container-fluid -->
 <?php include('site-footer.php'); ?>