<?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['selling_image_name']['name']; 

$image_names= time()."_".$image_name;

?>  

  <?php

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

$selling_name=$_REQUEST['selling_name'];

$sqlinsrt="insert into tbl_selling set

selling_name='$selling_name',

selling_image_name='$image_names'";

 mysql_query($sqlinsrt);

 move_uploaded_file($_FILES['selling_image_name']['tmp_name'],"../add-images/".$image_names);         

}

?> 

<?php

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

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

						if($_FILES['selling_image_name']['name']==""){ 

$sqlu="select * from tbl_selling where selling_id='$_REQUEST[selling_id]'";

$datau=mysql_query($sqlu);

$resultu=mysql_fetch_array($datau);

$image_names=$resultu['selling_image_name'];

		}

$selling_name=$_REQUEST['selling_name'];

$sqlUp="update tbl_selling set 

selling_name='$selling_name',

selling_image_name='$image_names'

where selling_id='$_REQUEST[selling_id]'";

$data=mysql_query($sqlUp);

header('location:manage-adventure-image.php');

move_uploaded_file($_FILES['selling_image_name']['tmp_name'],"../add-images/".$image_names);         

}}

?> 

<?php 

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

$del_selling_id=$_REQUEST['del_selling_id'];

$sql="delete from tbl_selling where selling_id='$del_selling_id'";

$data=mysql_query($sql);

}

?>

<?php 

$sqlImage="select * from tbl_selling";

$data=mysql_query($sqlImage);

$count=mysql_num_rows($data);

?>

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

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

        <h1>Dashboard</h1>

        <p class="lead">Update your Selling Trips / Selling Trips</strong>.</p>

      </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 Selling Trips / Selling Trips</li>

        </ol>

      </div>

    </section>

    <!-- / PAGE TITLE -->

    <div class="container-fluid">

      <div class="row">

      <?php

                while($resultImg=mysql_fetch_array($data)){

				?> 

                 <form method="post" enctype="multipart/form-data" style="margin-top:50px;">

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

         <section class="panel tasks-widget"> <img  src="../add-images/<?php echo $resultImg['selling_image_name'];?>" class="img-responsive" style="height:200px; width:100%;"> </section>

            <div class="text-center"> <input type="text" name="selling_name" value="<?php echo $resultImg['selling_name'];?>" placeholder="Image Name" style="color:#bd5151; width:100%;"> </div><br>

          <div class="text-center"> <input type="file" name="selling_image_name" class="btn btn-primary"> </div>

           <div class="text-center"> <input type="hidden" name="selling_id" value="<?php echo $resultImg['selling_id'];?>" class="btn btn-primary"> </div>

             

          <div class="text-center"> <button type="submit" name="Updt" class="btn btn-primary" style="float:right; width:100%;">Update  </button></div>

          </form><form method="post">

           <div class="text-center"> <input type="hidden" name="del_selling_id" value="<?php echo $resultImg['selling_id'];?>" class="btn btn-primary"> </div>

           <div class="text-center"> <button type="submit" name="Updt" class="btn btn-primary" style="float:right; width:100%;">Delete  </button></div></form>

        </div>

        

          

        <?php } ?>

       

      </div>

      <!-- / row -->

    </div>

    <div class="container-fluid" style="margin-top:80px;">

      <div class="row">

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

         

        </div>

        <?php 

		if($count>='5'){

		echo "";

		}

		else

		{

			?>

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

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

      <div class="text-center"> <input type="file" name="selling_image_name" class="btn btn-primary"> </div><br>

                 <div class="text-center"> <input type="text" name="selling_name" placeholder="Image Name" style=" width:100%;" > </div><br>

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

        </div>

        </form>

        <?php } ?>

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

          

        </div>

      </div>

      <!-- / row -->

    </div>

    

    <!-- / container-fluid -->

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