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

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

?>  

  <?php

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

$adventure_name=$_REQUEST['adventure_name'];

$sqlinsrt="insert into tbl_adventure set

adventure_name='$adventure_name',

adventure_image_name='$image_names'";

 mysql_query($sqlinsrt);

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

}

?> 

<?php

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

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

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

$sqlu="select * from tbl_adventure where adventure_id='$_REQUEST[adventure_id]'";

$datau=mysql_query($sqlu);

$resultu=mysql_fetch_array($datau);

$image_names=$resultu['adventure_image_name'];

		}

$adventure_name=$_REQUEST['adventure_name'];

$sqlUp="update tbl_adventure set 

adventure_name='$adventure_name',

adventure_image_name='$image_names'

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

$data=mysql_query($sqlUp);

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

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

}}

?> 

<?php 

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

$del_adventure_id=$_REQUEST['del_adventure_id'];

$sql="delete from tbl_adventure where adventure_id='$del_adventure_id'";

$data=mysql_query($sql);

}

?>

<?php 

$sqlImage="select * from tbl_adventure";

$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 Adventure / Adventure Image</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 Adventure / Adventure Image</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">

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

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

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

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

           <div class="text-center"> <input type="hidden" name="adventure_id" value="<?php echo $resultImg['adventure_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_adventure_id" value="<?php echo $resultImg['adventure_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>='8'){

		echo "";

		}

		else

		{

			?>

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

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

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

                 <div class="text-center"> <input type="text" name="adventure_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'); ?>