<?php

$table_name = 'home_page_details';
$redirection_page = "index.php?action=$page_name";
$action_name = "action=$page_name";
$type = $_REQUEST['type'];
$edit_id = $_REQUEST['edit_id'];
$delete_id = $_REQUEST['delete_id'];


// For Submitting The Form

if (isset($_POST['submit'])) {

  $field1    =  $_POST['field1'];
  $field2    =  $_POST['field2'];
  $field12    =  $_POST['field12'];


  $allow = array("jpg", "JPG", "jpeg", "JPEG", "gif", "GIF", "png", "PNG", "pdf", "PDF");
  //1st File
  if ($_FILES['photo1']['name'] == "") {
    //echo "No Image"
  } else {

    $photo1 = basename($_FILES['photo1']['name']);
    $extension = pathinfo($photo1, PATHINFO_EXTENSION);
    if (in_array($extension, $allow)) {
      $target_path = "assets/images/Home-img/";
      $photo1 = md5(rand() * time()) . '.' . $extension;
      $target_path = $target_path . $photo1;
      move_uploaded_file($_FILES['photo1']['tmp_name'], $target_path);
      $sql = ($photo1 != '') ? " home_img='$photo1' " . ',' : '';
    }
  }

  $allow = array("jpg", "JPG", "jpeg", "JPEG", "gif", "GIF", "png", "PNG", "pdf", "PDF");
  //1st File
  if ($_FILES['photo12']['name'] == "") {
    //echo "No Image"
  } else {

    $photo12 = basename($_FILES['photo12']['name']);
    $extension = pathinfo($photo12, PATHINFO_EXTENSION);
    if (in_array($extension, $allow)) {
      $target_path = "assets/images/Home-img/";
      $photo12 = md5(rand() * time()) . '.' . $extension;
      $target_path = $target_path . $photo12;
      move_uploaded_file($_FILES['photo12']['tmp_name'], $target_path);
      $sql12 = ($photo12 != '') ? " home_img='$photo12' " . ',' : '';
    }
  }
  //3RD
  $allow = array("jpg", "JPG", "jpeg", "JPEG", "gif", "GIF", "png", "PNG", "pdf", "PDF");
  //1st File
  if ($_FILES['photo123']['name'] == "") {
    //echo "No Image"
  } else {

    $photo123 = basename($_FILES['photo123']['name']);
    $extension = pathinfo($photo123, PATHINFO_EXTENSION);
    if (in_array($extension, $allow)) {
      $target_path = "assets/images/Home-img/";
      $photo123 = md5(rand() * time()) . '.' . $extension;
      $target_path = $target_path . $photo123;
      move_uploaded_file($_FILES['photo123']['tmp_name'], $target_path);
      $sql123 = ($photo123 != '') ? " home_img='$photo123' " . ',' : '';
    }
  }


  //4RD
  $allow = array("jpg", "JPG", "jpeg", "JPEG", "gif", "GIF", "png", "PNG", "pdf", "PDF");
  //1st File
  if ($_FILES['photo1234']['name'] == "") {
    //echo "No Image"
  } else {

    $photo1234 = basename($_FILES['photo1234']['name']);
    $extension = pathinfo($photo1234, PATHINFO_EXTENSION);
    if (in_array($extension, $allow)) {
      $target_path = "assets/images/Home-img/";
      $photo1234 = md5(rand() * time()) . '.' . $extension;
      $target_path = $target_path . $photo1234;
      move_uploaded_file($_FILES['photo1234']['tmp_name'], $target_path);
      $sql1234 = ($photo1234 != '') ? " home_img='$photo1234' " . ',' : '';
    }
  }
  //5th
  $allow = array("jpg", "JPG", "jpeg", "JPEG", "gif", "GIF", "png", "PNG", "pdf", "PDF");
  //1st File
  if ($_FILES['photo12345']['name'] == "") {
    //echo "No Image"
  } else {

    $photo12345 = basename($_FILES['photo12345']['name']);
    $extension = pathinfo($photo12345, PATHINFO_EXTENSION);
    if (in_array($extension, $allow)) {
      $target_path = "assets/images/Home-img/";
      $photo12345 = md5(rand() * time()) . '.' . $extension;
      $target_path = $target_path . $photo12345;
      move_uploaded_file($_FILES['photo12345']['tmp_name'], $target_path);
      $sql12345 = ($photo12345 != '') ? " home_img='$photo12345' " . ',' : '';
    }
  }
  //6th
  $allow = array("jpg", "JPG", "jpeg", "JPEG", "gif", "GIF", "png", "PNG", "pdf", "PDF");
  //1st File
  if ($_FILES['photo123456']['name'] == "") {
    //echo "No Image"
  } else {

    $photo123456 = basename($_FILES['photo123456']['name']);
    $extension = pathinfo($photo123456, PATHINFO_EXTENSION);
    if (in_array($extension, $allow)) {
      $target_path = "assets/images/Home-img/";
      $photo123456 = md5(rand() * time()) . '.' . $extension;
      $target_path = $target_path . $photo123456;
      move_uploaded_file($_FILES['photo123456']['tmp_name'], $target_path);
      $sql123456 = ($photo123456 != '') ? " home_img='$photo123456' " . ',' : '';
    }
  }
  $allow = array("jpg", "JPG", "jpeg", "JPEG", "gif", "GIF", "png", "PNG", "pdf", "PDF");
  //1st File
  if ($_FILES['photo1234567']['name'] == "") {
    //echo "No Image"
  } else {

    $photo1234567 = basename($_FILES['photo1234567']['name']);
    $extension = pathinfo($photo1234567, PATHINFO_EXTENSION);
    if (in_array($extension, $allow)) {
      $target_path = "assets/images/Home-img/";
      $photo1234567 = md5(rand() * time()) . '.' . $extension;
      $target_path = $target_path . $photo1234567;
      move_uploaded_file($_FILES['photo1234567']['tmp_name'], $target_path);
      $sql1234567 = ($photo1234567 != '') ? " home_img='$photo1234567' " . ',' : '';
    }
  }


  $insert_bookings = "UPDATE `$table_name` SET
  $sql
  home_type   = 'home_product'   
  where id='4'";
  $sql_insert = $dbconn->prepare($insert_bookings);
  $sql_insert->execute();
  $message = "Details successfully updated.";
  $status = "success";
  header("Location: $redirection_page");

  $insert_bookings = "UPDATE `$table_name` SET
  $sql12
  home_type   = 'home_product'   
  where id='5'";
  $sql_insert = $dbconn->prepare($insert_bookings);
  $sql_insert->execute();
  $message = "Details successfully updated.";
  $status = "success";
  header("Location: $redirection_page");

  $insert_bookings = "UPDATE `$table_name` SET
  $sql123
  home_type   = 'home_product'   
  where id='6'";
  $sql_insert = $dbconn->prepare($insert_bookings);
  $sql_insert->execute();
  $message = "Details successfully updated.";
  $status = "success";
  header("Location: $redirection_page");

  $insert_bookings = "UPDATE `$table_name` SET
  $sql1234
  home_type   = 'home_product'   
  where id='7'";
  $sql_insert = $dbconn->prepare($insert_bookings);
  $sql_insert->execute();
  $message = "Details successfully updated.";
  $status = "success";
  header("Location: $redirection_page");

  $insert_bookings = "UPDATE `$table_name` SET
  $sql12345
  home_type   = 'home_product'   
  where id='8'";
  $sql_insert = $dbconn->prepare($insert_bookings);
  $sql_insert->execute();
  $message = "Details successfully updated.";
  $status = "success";
  header("Location: $redirection_page");

  $insert_bookings = "UPDATE `$table_name` SET
  $sql123456
  home_type   = 'home_product'   
  where id='9'";
  $sql_insert = $dbconn->prepare($insert_bookings);
  $sql_insert->execute();
  $message = "Details successfully updated.";
  $status = "success";
  header("Location: $redirection_page");

  $insert_bookings = "UPDATE `$table_name` SET
  $sql1234567
  home_type   = 'home_product'   
  where id='10'";
  $sql_insert = $dbconn->prepare($insert_bookings);
  $sql_insert->execute();
  $message = "Details successfully updated.";
  $status = "success";
  header("Location: $redirection_page");


  $insert_bookings = "UPDATE `$table_name` SET
  $sql12345678
  home_type   = 'home_product'   
  where id='11'";
  $sql_insert = $dbconn->prepare($insert_bookings);
  $sql_insert->execute();
  $message = "Details successfully updated.";
  $status = "success";
  header("Location: $redirection_page");
}

if (isset($_GET['pageno'])) {
  $pageno = $_GET['pageno'];
} else {
  $pageno = 1;
}
$no_of_records_per_page = 20;
$offset = ($pageno - 1) * $no_of_records_per_page;


$select_enquiry = "SELECT * FROM $table_name where status = 'Active' order by id desc";
$sql = $dbconn->prepare($select_enquiry);
$sql->execute();
$total_rows = $sql->fetchColumn();
$total_pages = ceil($total_rows / $no_of_records_per_page);

//         $select_enquiry = "SELECT * FROM $table_name where status = 'Active' order by id desc LIMIT $offset, $no_of_records_per_page";
// $sql=$dbconn->prepare($select_enquiry);
//  $sql->execute();
//  $wlvd=$sql->fetchAll(PDO::FETCH_OBJ);


$select_bookings = "SELECT * FROM `$table_name` WHERE id = '4'";
$sql1 = $dbconn->prepare($select_bookings);
$sql1->execute();
$wlvd1 = $sql1->fetchAll(PDO::FETCH_OBJ);
foreach ($wlvd1 as $rows1);

//2nd tor babe
$select_bookings12 = "SELECT * FROM `$table_name` WHERE id = '5'";
$sql12 = $dbconn->prepare($select_bookings12);
$sql12->execute();
$wlvd12 = $sql12->fetchAll(PDO::FETCH_OBJ);
foreach ($wlvd12 as $rows12);
//3rd 
$select_bookings123 = "SELECT * FROM `$table_name` WHERE id = '6'";
$sql123 = $dbconn->prepare($select_bookings123);
$sql123->execute();
$wlvd123 = $sql123->fetchAll(PDO::FETCH_OBJ);
foreach ($wlvd123 as $rows123);

$select_bookings1234 = "SELECT * FROM `$table_name` WHERE id = '7'";
$sql1234 = $dbconn->prepare($select_bookings1234);
$sql1234->execute();
$wlvd1234 = $sql1234->fetchAll(PDO::FETCH_OBJ);
foreach ($wlvd1234 as $rows1234);

$select_bookings12345 = "SELECT * FROM `$table_name` WHERE id = '8'";
$sql12345 = $dbconn->prepare($select_bookings12345);
$sql12345->execute();
$wlvd12345 = $sql12345->fetchAll(PDO::FETCH_OBJ);
foreach ($wlvd12345 as $rows12345);

$select_bookings123456 = "SELECT * FROM `$table_name` WHERE id = '9'";
$sql123456 = $dbconn->prepare($select_bookings123456);
$sql123456->execute();
$wlvd123456 = $sql123456->fetchAll(PDO::FETCH_OBJ);
foreach ($wlvd123456 as $rows123456);

$select_bookings1234567 = "SELECT * FROM `$table_name` WHERE id = '10'";
$sql1234567 = $dbconn->prepare($select_bookings1234567);
$sql1234567->execute();
$wlvd1234567 = $sql1234567->fetchAll(PDO::FETCH_OBJ);
foreach ($wlvd1234567 as $rows1234567);

$select_bookings12345678 = "SELECT * FROM `$table_name` WHERE id = '11'";
$sql12345678 = $dbconn->prepare($select_bookings12345678);
$sql12345678->execute();
$wlvd12345678 = $sql12345678->fetchAll(PDO::FETCH_OBJ);
foreach ($wlvd12345678 as $rows12345678);


?>


<div class="container-fluid">

  <div class="content-wrapper">
    <div class="container-fluid">
      <!-- Breadcrumb-->
      <div class="row pt-2 pb-2">
        <div class="col-sm-9">
          <h4 class="page-title"><?php echo $page_name; ?></h4>
          <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="index.php?action=Welcome">Dashboard</a></li>

            <li class="breadcrumb-item active" aria-current="page"><a href="index.php?action=<?php echo $page_name; ?>"><?php echo $page_name; ?></a></li>
          </ol>
        </div>

        <div class="col-sm-3">
          <?php include('plugins/alert.php'); ?>
          <!-- Button trigger modal -->
        </div>
      </div>
      <!-- End Breadcrumb-->

      <div class="row">
        <div class="col-lg-4">
          <div class="card">

            <div class="card-body">
              <div class="table-responsive">

                <form id="formID" class="m-t-30" method="post" action="" enctype="multipart/form-data">


                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group">
                        <label for="inv_phone">Product IMAGE NO 1</label>

                        <input name="photo1" type="file" id="photo1" class="form-control">

                        <small id="emailHelp" class="form-text text-muted"></small>
                      </div>

                    </div>
                  </div>
                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group">
                        <label for="inv_phone">Product IMAGE NO 2</label>

                        <input name="photo12" type="file" id="photo12" class="form-control">

                        <small id="emailHelp" class="form-text text-muted"></small>
                      </div>
                    </div>
                  </div>
                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group">
                        <label for="inv_phone">Product IMAGE NO 3 </label>
                        <input name="photo123" type="file" id="photo123" class="form-control">
                        <small id="emailHelp" class="form-text text-muted"></small>
                      </div>
                    </div>
                  </div>
                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group">
                        <label for="inv_phone">Product IMAGE NO 4 </label>
                        <input name="photo1234" type="file" id="photo1234" class="form-control">
                        <small id="emailHelp" class="form-text text-muted"></small>
                      </div>
                    </div>
                  </div>
                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group">
                        <label for="inv_phone">Product IMAGE NO 5 </label>
                        <input name="photo12345" type="file" id="photo12345" class="form-control">
                        <small id="emailHelp" class="form-text text-muted"></small>
                      </div>
                    </div>
                  </div>
                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group">
                        <label for="inv_phone">Product IMAGE NO 6 </label>
                        <input name="photo123456" type="file" id="photo123456" class="form-control">
                        <small id="emailHelp" class="form-text text-muted"></small>
                      </div>
                    </div>
                  </div>
                  <div class="row">
                    <div class="col-md-12">
                      <div class="form-group">
                        <label for="inv_phone">Product IMAGE NO 7 </label>
                        <input name="photo1234567" type="file" id="photo1234567" class="form-control">
                        <small id="emailHelp" class="form-text text-muted"></small>
                      </div>
                    </div>
                  </div>


                  <button type="submit" name="submit" value="Submit" class="btn btn-primary btn-lg btn-block waves-effect waves-light m-1">UPDATE</button>

                </form>
              </div>
            </div>
          </div>
        </div>

        <div class="col-lg-8">
          <div class="card">
            <div class="card-body">
              <div class="table-responsive">

                <table class="table table-hover" id="sample-table-1">
                  <thead class="thead-dark">
                    <tr>
                      <th class="center"> ID</th>
                      <th class="center">Slider IMAGE</th>

                    </tr>
                  </thead>
                  <tbody>
                    <?php

                    //while($rows = mysql_fetch_array($aResult,MYSQL_ASSOC))
                    //{ 
                    if ($sql->rowCount() > 0) {
                      foreach ($wlvd1 as $rows1) {
                        $field1 = $rows1->id;
                        $field3 = $rows1->home_img;
                    ?>
                        <tr>
                          <td class="center"><?php echo $field1; ?></td>
                          <td class="center"><img style="height:150px; width:250px" src="assets/images/Home-img/<?php echo $field3; ?>"></td>

                        </tr>

                    <?php
                      }
                    }
                    ?>
                  </tbody>
                </table>
              </div>


              <div class="table-responsive">

                <table class="table table-hover" id="sample-table-1">
                  <thead class="thead-dark">
                    <!--   <tr>
                        <th class="center"> ID</th>
                        <th class="center">Home Slider Image2</th> 
                       
                      </tr> -->
                  </thead>
                  <tbody>
                    <?php

                    //while($rows = mysql_fetch_array($aResult,MYSQL_ASSOC))
                    //{ 
                    if ($sql->rowCount() > 0) {
                      foreach ($wlvd12 as $rows12) {
                        $field12 = $rows12->id;
                        $field123 = $rows12->home_img;

                    ?>
                        <tr>
                          <td class="center"><?php echo $field12; ?></td>
                          <td class="center"><img style="height:150px; width:250px" src="assets/images/Home-img/<?php echo $field123; ?>"></td>

                        </tr>

                    <?php
                      }
                    }
                    ?>
                  </tbody>
                </table>

              </div>

              <div class="table-responsive">

                <table class="table table-hover" id="sample-table-1">
                  <thead class="thead-dark">
                    <!--  <tr>
                        <th class="center"> ID</th>
                        <th class="center">Home Slider Image3</th> 
                       
                      </tr> -->
                  </thead>
                  <tbody>
                    <?php

                    //while($rows = mysql_fetch_array($aResult,MYSQL_ASSOC))
                    //{ 
                    if ($sql->rowCount() > 0) {
                      foreach ($wlvd123 as $rows123) {
                        $field12 = $rows123->id;

                        $field123 = $rows123->home_img;




                    ?>
                        <tr>
                          <td class="center"><?php echo $field12; ?></td>
                          <td class="center"><img style="height:150px; width:250px" src="assets/images/Home-img/<?php echo $field123; ?>"></td>



                        </tr>

                    <?php
                      }
                    }
                    ?>
                  </tbody>
                </table>



              </div>
              <div class="table-responsive">

                <table class="table table-hover" id="sample-table-1">
                  <thead class="thead-dark">
                    <!--  <tr>
                        <th class="center"> ID</th>
                        <th class="center">Home Slider Image3</th> 
                       
                      </tr> -->
                  </thead>
                  <tbody>
                    <?php

                    //while($rows = mysql_fetch_array($aResult,MYSQL_ASSOC))
                    //{ 
                    if ($sql->rowCount() > 0) {
                      foreach ($wlvd1234 as $rows1234) {
                        $field12 = $rows1234->id;

                        $field123 = $rows1234->home_img;




                    ?>
                        <tr>
                          <td class="center"><?php echo $field12; ?></td>
                          <td class="center"><img style="height:150px; width:250px" src="assets/images/Home-img/<?php echo $field123; ?>"></td>



                        </tr>

                    <?php
                      }
                    }
                    ?>
                  </tbody>
                </table>



              </div>
              <div class="table-responsive">

                <table class="table table-hover" id="sample-table-1">
                  <thead class="thead-dark">
                    <!--  <tr>
                        <th class="center"> ID</th>
                        <th class="center">Home Slider Image3</th> 
                       
                      </tr> -->
                  </thead>
                  <tbody>
                    <?php

                    //while($rows = mysql_fetch_array($aResult,MYSQL_ASSOC))
                    //{ 
                    if ($sql->rowCount() > 0) {
                      foreach ($wlvd12345 as $rows12345) {
                        $field12 = $rows12345->id;

                        $field123 = $rows12345->home_img;




                    ?>
                        <tr>
                          <td class="center"><?php echo $field12; ?></td>
                          <td class="center"><img style="height:150px; width:250px" src="assets/images/Home-img/<?php echo $field123; ?>"></td>



                        </tr>

                    <?php
                      }
                    }
                    ?>
                  </tbody>
                </table>



              </div>
              <div class="table-responsive">

                <table class="table table-hover" id="sample-table-1">
                  <thead class="thead-dark">
                    <!--  <tr>
                        <th class="center"> ID</th>
                        <th class="center">Home Slider Image3</th> 
                       
                      </tr> -->
                  </thead>
                  <tbody>
                    <?php

                    //while($rows = mysql_fetch_array($aResult,MYSQL_ASSOC))
                    //{ 
                    if ($sql->rowCount() > 0) {
                      foreach ($wlvd123456 as $rows123456) {
                        $field12 = $rows123456->id;

                        $field123 = $rows123456->home_img;




                    ?>
                        <tr>
                          <td class="center"><?php echo $field12; ?></td>
                          <td class="center"><img style="height:150px; width:250px" src="assets/images/Home-img/<?php echo $field123; ?>"></td>



                        </tr>

                    <?php
                      }
                    }
                    ?>
                  </tbody>
                </table>



              </div>
              <div class="table-responsive">

                <table class="table table-hover" id="sample-table-1">
                  <thead class="thead-dark">
                    <!--  <tr>
                        <th class="center"> ID</th>
                        <th class="center">Home Slider Image3</th> 
                      
                      </tr> -->
                  </thead>
                  <tbody>
                    <?php

                    //while($rows = mysql_fetch_array($aResult,MYSQL_ASSOC))
                    //{ 
                    if ($sql->rowCount() > 0) {
                      foreach ($wlvd1234567 as $rows1234567) {
                        $field12 = $rows1234567->id;

                        $field123 = $rows1234567->home_img;




                    ?>
                        <tr>
                          <td class="center"><?php echo $field12; ?></td>
                          <td class="center"><img style="height:150px; width:250px" src="assets/images/Home-img/<?php echo $field123; ?>"></td>



                        </tr>

                    <?php
                      }
                    }
                    ?>
                  </tbody>
                </table>
              </div>



            </div>
          </div>
        </div>

      </div>
      <!-- End Row-->
    </div>
    <!--End content-wrapper-->

    <!--Start Back To Top Button-->
    <a href="javaScript:void();" class="back-to-top"><i class="fa fa-angle-double-up"></i> </a>
    <!--End Back To Top Button-->