/home/hdwebsolution/public_html/ns-interior/admin-pages/New folder (2)/update-online-links.php
<?php include('site-header.php'); ?>
  <!-- end of LOGO CONTAINER -->
  <!-- - - - - - - - - - - - - -->
  <!-- start of SIDEBAR        -->
  <!-- - - - - - - - - - - - - -->
  <?php include('left-nevigation.php'); ?>
  <!-- - - - - - - - - - - - - -->
  <!-- end of SIDEBAR          -->
  <!-- - - - - - - - - - - - - -->
  <main id="playground">
    <!-- - - - - - - - - - - - - -->
    <!-- start of TOP NAVIGATION -->
    <!-- - - - - - - - - - - - - -->
     <?php include('site-top-header.php'); ?>
    <!-- - - - - - - - - - - - - -->
    <!-- end of TOP NAVIGATION   -->
    <!-- - - - - - - - - - - - - -->
    <!-- PAGE TITLE -->
<?php 
$image_name=$_FILES['banner_image_name']['name']; 
$image_names= time()."_".$image_name;
$himage = $_REQUEST['himage'];
?>
<?php
if(isset($_REQUEST['Insert']))
{
        
        $sql_Up = "INSERT INTO `tbl_banner`(`banner_image_name`, `banner_type`) VALUES ('$image_names','1')";
        if(mysqli_query($link,$sql_Up))
            {
              move_uploaded_file($_FILES['banner_image_name']['tmp_name'],"../header-image/".$image_names);
              $msg = "<p style='color:green;'>Save Banner Successfully!!!</p>";
            }    
}
?> 
<?php
if(isset($_REQUEST['Updt']))
{       
    extract($_POST);
        
        if($_FILES['banner_image_name']['name']!=="")
        {
          $sql_up_ing = "UPDATE `tbl_banner` SET 
                                `banner_name`='$banner_name',
                                `banner_decs`='$banner_decs',
                                `banner_image_name`='$image_names',
                                `banner_link`= '$banner_link'
                                 WHERE banner_id='$img_id'";
            if(mysqli_query($link,$sql_up_ing))
                  {
                    unlink("../header-image/$himage");
                    move_uploaded_file($_FILES['banner_image_name']['tmp_name'],"../header-image/".$image_names);
                    $msg = "<p style='color:Green;'>Update Successfully!!!</p>";
                  }
        }
        else
        {
            $sql_up_ing = "UPDATE `tbl_banner` SET 
                                `banner_name`='$banner_name',
                                `banner_decs`='$banner_decs',
                                `banner_link`= '$banner_link'
                                 WHERE banner_id='$img_id'";
              if(mysqli_query($link,$sql_up_ing))
                  {
                    $msg = "<p style='color:orange;'>Update Successfully!!!</p>";
                  }
        }
               
}
?> 
<?php 
if($_REQUEST['del_banner_id']!="")
{
      $del_banner_id=$_REQUEST['del_banner_id'];
      $sql="delete from tbl_banner where banner_id='$del_banner_id'";
      if(mysqli_query($link,$sql))
                  {
                    unlink("../header-image/$himage");
                    $msg = "<p style='color:red;'>Delete Successfully!!!</p>";
                  }
}
?>
<?php
      $sql="SELECT * FROM `tbl_banner` WHERE `banner_type`='1'";
      $data = mysqli_query($link,$sql);
      $count=mysqli_num_rows($data)
?>
     
    <section id="page-title" class="row">
      <div class="col-md-8">
        <h1>Home Buy Online </h1>
       
        <!-- <p class="lead">Update your Home Third Party Products image </strong>.</p> -->
        <!-- <p style="font-weight: bold;font-size:18px;">
            Image Size(340 x 300)Pixel            
        </p> -->
        <?=$msg;?>
      </div>
      <div class="col-md-4">
        <ol class="breadcrumb pull-right no-margin-bottom">
         
          <li><a href="dashboard.php">Dashboard</a></li>
          <li class="active">Update Home Buy Online </li>
        </ol>
      </div>
    </section>

<section>
<div class="container">
<div class="row">
<div class="col-lg-12">
<!-- <a href="update-about-us.php" class="btn btn-primary">Back</a> -->
</div>
</div>
</div>
</section>


    <!-- / PAGE TITLE -->
    <div class="container-fluid">
      <div class="row">
      <?php while($result=mysqli_fetch_array($data)){ ?>
      <form enctype="multipart/form-data" method="post">
         <div class="col-md-4">
          <section class="panel tasks-widget"> 
            <!-- <embed  src="../header-image/<?=$result['banner_image_name']; ?>" style="width:100%;" ></embed> -->
            <!-- <img  src="../header-image/<?=$result['banner_image_name']; ?>" class="img-responsive" style="width:100%px; height:200px; text-align: center; margin: 0 auto;"> 
          </section>
          <div class="text-center">
            <input type="file" name="banner_image_name">
          </div> -->
          <input type="text" name="banner_name" placeholder="Title" class="form-control" value="<?=$result['banner_name'];?>">
          <!-- <textarea name="banner_decs" placeholder="Description......" class="form-control" style="width: 100%; height:100px;">
             <?=$result['banner_decs'];?>
          </textarea>  -->
          <input type="text" name="banner_link" placeholder=" Link....." class="form-control" value="<?=$result['banner_link']; ?>" >
          
          <input type="hidden" name="img_id" value="<?php echo $result['banner_id'] ?>">
          <input type="hidden" name="himage" value="<?php echo $result['banner_image_name'] ?>">
          <div class="text-center"><button class="btn btn-primary" name="Updt" style="width:100%;">Update</button></a> </div>
          </form>
          <form method="post">
           <input type="hidden" name="del_banner_id" value="<?php echo $result['banner_id'] ?>">
            <input type="hidden" name="himage" value="<?php echo $result['banner_image_name'] ?>">
          <!-- <div class="text-center"><button class="btn btn-primary" name="del" style="width:100%;">Delete</button></a> </div> -->
         </div>
        </form>
        <?php } ?>
      </div>
      <!-- / row -->
    </div>
    <?php if($count>=3){
	echo "";
	}else{
		
		
		 ?>
    <div class="container-fluid" style="margin-top:80px;">
      <div class="row">
        <div class="col-md-4">
         
        </div>
        <form method="post" enctype="multipart/form-data">
        <div class="col-md-4">
            <!-- <div class="text-center"> 
              <input type="file" name="banner_image_name" class="btn btn-primary"> 
             
            </div> -->
            <br>
          <div class="text-center"> <button type="submit" name="Insert" class="btn btn-primary" style=" width:100%;">Add  </button></div>
        </div>
        </form>
        <div class="col-md-4">
          
        </div>
      </div>
      <!-- / row -->
    </div>
    <?php } ?>
    <!-- / container-fluid -->
<?php include('site-footer.php'); ?>


<script type="text/javascript">
  $('document').ready(function()
{
    $('textarea').each(function(){
            $(this).val($(this).val().trim());
        }
    );
});
</script>