<?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;

?>

<?php

if(isset($_REQUEST['Insert'])){

$banner_link=$_REQUEST['banner_link'];

$sqlinsrt="insert into tbl_banner set

banner_link='$banner_link',

banner_image_name='$image_names'";

mysql_query($sqlinsrt);

move_uploaded_file($_FILES['banner_image_name']['tmp_name'],"../header-image/".$image_names);         

}

?> 

<?php

if(isset($_REQUEST['Updt'])){

$banner_link=$_REQUEST['banner_link'];

$sqlinsrt="update tbl_banner set

banner_link='$banner_link',

banner_image_name='$image_names'

where banner_id='$_REQUEST[img_id]'";

mysql_query($sqlinsrt);

move_uploaded_file($_FILES['banner_image_name']['tmp_name'],"../header-image/".$image_names);         

}

?> 

<?php 

if($_REQUEST['del_banner_id']!=""){

$del_banner_id=$_REQUEST['del_banner_id'];

$sql="delete from tbl_banner where banner_id='$del_banner_id'";

$data=mysql_query($sql);

}

?>

<?php

$sql="select * from tbl_banner where 1";

$data=mysql_query($sql);

$count=mysql_num_rows($data)

?>

     

    <section id="page-title" class="row">

      <div class="col-md-8">

        <h1>Dashboard</h1>

        <p class="lead">Update your banner image in home page</strong>.</p>

      </div>

      <div class="col-md-4">

        <ol class="breadcrumb pull-right no-margin-bottom">

         

          <li><a href="dashboard.html">Dashboard</a></li>

          <li class="active">Update Banner Image</li>

        </ol>

      </div>

    </section>

    <!-- / PAGE TITLE -->

    <div class="container-fluid">

      <div class="row">

      <?php while($result=mysql_fetch_array($data)){ ?>

      <form enctype="multipart/form-data" method="post">

         <div class="col-md-4">

          <section class="panel tasks-widget"> <img  src="../header-image/<?php echo $result['banner_image_name']; ?>" class="img-responsive" style="width:100%; height:280px;"> </section>

          <input type="text" name="banner_link" placeholder="Banner Link" value="<?php echo $result['banner_link']; ?>" style="width:100%;"> 

          <div class="text-center"><input type="file" placeholder="image" name="banner_image_name"></div>

          <input type="hidden" name="img_id" value="<?php echo $result['banner_id'] ?>">

      

          <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'] ?>">

      

          <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>=2){

	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"> 

       <input type="text" name="banner_link" style="width:100%;"> 

      

      </div><br>

          <div class="text-center"> <button type="submit" name="Insert" class="btn btn-primary" style=" width:100%;">Add Banner </button></div>

        </div>

        </form>

        <div class="col-md-4">

          

        </div>

      </div>

      <!-- / row -->

    </div>

    <?php } ?>

    <!-- / container-fluid -->

<?php include('site-footer.php'); ?>