Home »
Gallery
Gallery
include('config.php');
// how many rows to show per page
$rowsPerPage = 21;
// by default we show first page
$pageNum = 1;
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
$pagenum1 = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
$query = " SELECT * FROM `gallery` order by id desc " .
" LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error1, query failed');
$row_count = 0;
$j=1;
while($row = mysql_fetch_array($result))
{ ?>
=$row['title'];?>
$row_count++;
$j++;
} ?>
// how many rows we have in database
$query = "SELECT COUNT(*) AS numrows FROM `gallery`";
$result = mysql_query($query) or die('Error, query failed');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
// print the link to access each page
$self = $_SERVER['PHP_SELF'];
$nav = '';
if($maxPage > 5)
{
for($page = 1; $page <= 5; $page++)
{
if ($page == $pageNum)
{
$nav .= "
". $page." "; // no need to create a link to current page
}
else
{
$nav .= "
$page ";
}
}
}
else if($maxPage > 1)
{
for($page = 1; $page <= $maxPage; $page++)
{
if ($page == $pageNum)
{
$nav .= "
". $page." "; // no need to create a link to current page
}
else
{
$nav .= "
$page ";
}
}
}
// creating previous and next link
// plus the link to go straight to
// the first and last page
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = "
<< Prev ";
//$first = "
[First Page] ";
}
else
{
$prev = ' '; // we're on page one, don't print previous link
// $first = ' '; // nor the first page link
}
if ($pageNum < $maxPage)
{
$page = $pageNum + 1;
$next = "
Next >> ";
// $last = "
[Last Page] ";
}
else
{
$next = ' '; // we're on the last page, don't print next link
// $last = ' '; // nor the last page link
}
// print the navigation link
if($pagenum1 > 5)
{
echo "
". $prev ."     ". $next."
";
}
else
{
echo "
". $prev ."     " . $nav ."     " . $next."
";
}
if($j==1)
{
?>
No Gallery Found |
}
?>
Facts and Figures about Kishanganj » |
Kishanganj Tourism » |
Irani Basti in Kishanganj »