// how many rows to show per page
$rowsPerPage = 6;
// 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 = mysql_query("SELECT * FROM gallery LIMIT $offset, $rowsPerPage");
// how many rows we have in database
$queryp = "SELECT COUNT(id) AS numrows FROM gallery";
$result = mysql_query($queryp) 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 = '';
for($page = 1; $page <= $maxPage; $page++) {
if ($page == $pageNum) {
$nav .= " $page "; // no need to create a link to current page
} else {
$nav .= " $page ";
}
}
if (mysql_num_rows($query) > 0) {
while ($gd = mysql_fetch_assoc($query)) {
if ($gd['id'] % 2) {
$rid = $gd['id'];
if (!empty($gd['image_path'])) {
$thumb_path= "./gallery/".$gd['image_path'];
$big_path= "./gallery/".$gd['image_path'];
$caption= $gd['caption'];
//$caption=addslashes($gd['caption']);
} else {
$thumb_path= "images/noimage_37.jpg";
$big_path="images/noimage_37.jpg";
}
}
}
}
?>
$rid = $rid + '1'; ?>
$queryb = mysql_query("SELECT * FROM gallery WHERE id = $rid");
$gdb = mysql_fetch_assoc ($queryb);
if (!empty($gdb['image_path'])){
$thumb_path= "./gallery/".$gdb['image_path'];
$big_path= "./gallery/".$gdb['image_path'];
//$caption = addslashes($gdb['caption']);
$caption = $gdb['caption'];
} else {
$thumb_path= "./images/noimage_37.jpg";
$big_path="./images/noimage_37.jpg";
}?>
}}}?>
click thumbnail for full size image >>
if ($pageNum > 1) {
$page = $pageNum - 1;
$prev = " << previous ";
} else {
$prev = ' '; // we're on page one, don't print previous link
}
if ($pageNum < $maxPage) {
$page = $pageNum + 1;
$next = " next >> ";
} else {
$next = ' '; // we're on the last page, don't print next link
}
?>