<?php 
include('header.php'); 

if ($_GET['del_id'] != ""){				
				
				$sel_id = mysqli_escape_string($conn, $_GET['del_id']);		
				
				// DELETE FRIEND
				$sql_del = "DELETE FROM feedback_tbl WHERE id = '$sel_id'";				
				mysqli_query($conn, $sql_del) or die(mysqli_error($conn));	
				
				$msg= "<font color=\"#FF0000\">Record deleted</font>";
}
?>
  
  

      
      <!--main content start-->
     <section id="main-content">
        <section class="wrapper">
		 
			  
              <div class="row">
                  <div class="col-lg-12">
                      <section class="panel">
                          <header class="panel-heading">
                              <b>FEEBACKS
                             </b>
						  </header>
                          <div class="panel-body">
              

 		
                          <?php
                                    if(isset($msg)){
										print $msg;	
									}
									?>
<table border="1" width="100%">
                              				<tr>
                                        	<th>Date Posted</th>
                                            <th>Email</th>
                                            <th>Phone</th>
                                            <th>Name</th>
                                            <th>Subject</th>
                                            <th>Message</th>
                                            <th></th>
                                        </tr>
                                                          



<?php
// how many rows to show per page
$rowsPerPage = 10;

// by default we show first page
$pageNum = 1;

// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
	$pageNum = $_GET['page'];
}

// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;


$query  = "SELECT * FROM feedback_tbl ";
$pagingQuery = "ORDER BY id DESC LIMIT $offset, $rowsPerPage";


$result = mysqli_query($conn, $query.$pagingQuery) or die(mysqli_error($conn));	

//loop through the query result and print 
while($info = mysqli_fetch_array($result)){

    $id = $info['id'];	
	$date_post = $info['date_post'];
	$client_email = $info['client_email'];
	$client_phone = $info['client_phone'];
	$client_name = $info['client_name'];
	$subject = $info['subject'];
	$question = $info['question'];
	$question = str_replace("\n", '<br />', $question);	
	
	print "
		<tr> 
			<td>$date_post</td>
			<td>$client_email</td>
			<td>$client_phone</td>
			<td>$client_name</td>
			<td>$subject</td>
			<td>$question</td>
			<td><a href=\"feedback.php?del_id=$id\">delete</a></td>                                  
		</tr>
	";
}
print "</table>";


// how many rows we have in database
$result  = mysqli_query($conn, $query) or die(mysqli_error($conn));
$numrows = mysqli_num_rows($result);

// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);

$self = $_SERVER['PHP_SELF'];

// creating 'previous' and 'next' link
// plus 'first page' and 'last page' link

// print 'previous' link only if we're not
// on page one
if ($pageNum > 1)
{
	$page = $pageNum - 1;
	$prev = " <a href=\"$self?page=$page\">[Prev]</a> ";

	$first = " <a href=\"$self?page=1\">[First Page]</a> ";
}
else
{
	$prev  = ' [Prev] ';       // we're on page one, don't enable 'previous' link
	$first = ' [First Page] '; // nor 'first page' link
}

// print 'next' link only if we're not
// on the last page
if ($pageNum < $maxPage)
{
	$page = $pageNum + 1;
	$next = " <a href=\"$self?page=$page\">[Next]</a> ";

	$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
}
else
{
	$next = ' [Next] ';      // we're on the last page, don't enable 'next' link
	$last = ' [Last Page] '; // nor 'last page' link
}

// print the page navigation link
echo $first . $prev . " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages " . $next . $last;

if ($maxPage == 0) {
print "<p><B>SORRY</B> No record found";
}
?>                                                       
                   
                          </div>
                      </section>
                  </div>
              </div>
                  
              <!-- project team & activity end -->

          </section>
      </section>
      <!--main content end-->
  </section>
  <!-- container section start -->

    <!-- javascripts -->
    <script src="js/jquery.js"></script>
	<script src="js/jquery-ui-1.10.4.min.js"></script>
    <script src="js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui-1.9.2.custom.min.js"></script>
    <!-- bootstrap -->
    <script src="js/bootstrap.min.js"></script>
    <!-- nice scroll -->
    <script src="js/jquery.scrollTo.min.js"></script>
    <script src="js/jquery.nicescroll.js" type="text/javascript"></script>
    <!-- charts scripts -->
    <script src="assets/jquery-knob/js/jquery.knob.js"></script>
    <script src="js/jquery.sparkline.js" type="text/javascript"></script>
    <script src="assets/jquery-easy-pie-chart/jquery.easy-pie-chart.js"></script>
    <script src="js/owl.carousel.js" ></script>
    <!-- jQuery full calendar -->
    <<script src="js/fullcalendar.min.js"></script> <!-- Full Google Calendar - Calendar -->
	<script src="assets/fullcalendar/fullcalendar/fullcalendar.js"></script>
    <!--script for this page only-->
    <script src="js/calendar-custom.js"></script>
	<script src="js/jquery.rateit.min.js"></script>
    <!-- custom select -->
    <script src="js/jquery.customSelect.min.js" ></script>
	<script src="assets/chart-master/Chart.js"></script>
   
    <!--custome script for all page-->
    <script src="js/scripts.js"></script>
    <!-- custom script for this page-->
    <script src="js/sparkline-chart.js"></script>
    <script src="js/easy-pie-chart.js"></script>
	<script src="js/jquery-jvectormap-1.2.2.min.js"></script>
	<script src="js/jquery-jvectormap-world-mill-en.js"></script>
	<script src="js/xcharts.min.js"></script>
	<script src="js/jquery.autosize.min.js"></script>
	<script src="js/jquery.placeholder.min.js"></script>
	<script src="js/gdp-data.js"></script>	
	<script src="js/morris.min.js"></script>
	<script src="js/sparklines.js"></script>	
	<script src="js/charts.js"></script>
	<script src="js/jquery.slimscroll.min.js"></script>
    
    <!-- custom chart script for this page only-->
    <script src="js/chartjs-custom.js"></script>
    
  <script>

      //knob
      $(function() {
        $(".knob").knob({
          'draw' : function () { 
            $(this.i).val(this.cv + '%')
          }
        })
      });

      //carousel
      $(document).ready(function() {
          $("#owl-slider").owlCarousel({
              navigation : true,
              slideSpeed : 300,
              paginationSpeed : 400,
              singleItem : true

          });
      });

      //custom select box

      $(function(){
          $('select.styled').customSelect();
      });
	  
	  /* ---------- Map ---------- */
	$(function(){
	  $('#map').vectorMap({
	    map: 'world_mill_en',
	    series: {
	      regions: [{
	        values: gdpData,
	        scale: ['#000', '#000'],
	        normalizeFunction: 'polynomial'
	      }]
	    },
		backgroundColor: '#eef3f7',
	    onLabelShow: function(e, el, code){
	      el.html(el.html()+' (GDP - '+gdpData[code]+')');
	    }
	  });
	});



  </script>

  </body>
</html>
