<?php

include("includes/include_all.php");

// how many rows to show per page
$rowsPerPage = 2;

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


// how many rows we have in database
$query   = "SELECT COUNT(*) AS numrows FROM post_blog where status='Y'";
$result  = tep_db_query($query,$conn) or die('Error, query failed');
$row     = tep_db_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];


$maxPage = ceil($numrows/$rowsPerPage);
$self = $_SERVER['PHP_SELF'];

/*$nav  = '';

for($page = 1; $page <= $maxPage; $page++)
{
   if ($page == $pageNum)
   {
      $nav .= " $page "; // no need to create a link to current page
   }
   else
   {
      $nav .= " <a href=\"$self?page=$page\">$page</a> ";
   }
}*/

if ($pageNum > 1)
{
   $page  = $pageNum - 1;
   $prev  = " <a href=\"$self?page=$page\">P r e v i o u s</a> ";

}
else
{
   $prev  = "P r e v i o u s".'&nbsp;'.'&nbsp;'.'&nbsp;'; 
  
}

if ($pageNum < $maxPage)
{
   $page = $pageNum + 1;
   $next = " <a href=\"$self?page=$page\">N e x t</a> ";

  
}
else
{
   $next = '&nbsp;'.'&nbsp;'.'&nbsp;'."N e x t"; 

}


?>
