PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
INCLUDE "conf.php3";
if ((!isset($gal))||(!isset($title[$gal]))){
print "<TITLE>Categories</TITLE>";
include "banner.php3";
print "<h1>Categories</h1>";
$i=0;
while (isset($title[$i])){
print "<h2><a href=$PHP_SELF?gal=$i>$title[$i]</a></h2>";
$i++;
};
}else{
?>
<TITLE><? print $title[$gal]; ?></TITLE>
</HEAD>
<BODY BACKGROUND="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000ff" VLINK="#800080" ALINK="#ff0000" >
<?
error_reporting(63);
include "banner.php3";
?>
<center>
<h1><? print $title[$gal] ?></h1>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?
if (!isset($pg)){
$pg=0;
};
$handle=opendir($dir[$gal]);
$i=0;
while ($file = readdir($handle)) {
if (eregi("jpg$",$file)){
$folder[$i]=$file;
$i=$i+1;
};
};
closedir($handle);
sort($folder);
$a=0;
$count=$row*$col*$pg;
for ($r=1; $r<=$row; $r++) {
print "<tr>";
if ($count>$i-1) {break;};
for ($c=1; $c<=$col; $c++) {
$tnpath=$tndir[$gal]."/".$folder[$count];
print "<td valign="center" align="center"><a href="view.php3?id=$folder[$count]&gal=$gal&pg=$pg&count=$count"><img src="$tnpath" BORDER=0></a><td valign="center">"; $count++;
if ($count>$i-1) {break;};
} ;
print "</tr>";
} ;
print "</table><h2>";
if ($pg>0) {
$tmp=$pg-1;;
print "<a href="$PHP_SELF?pg=$tmp&gal=$gal"><img src="prev.gif" alt="prev" width="30" height="20" border="0"></a>" ;
};
$tmp=$pg+1;
print "       ";
if ($tmp*$row*$col<$i) {
$tmp=$pg+1;
print "<a href="$PHP_SELF?pg=$tmp&gal=$gal"><img src="next.gif" alt="prev" width="30" height="20" border="0"></a>" ;
};
print "</h2>";
};
include "bannerbot.php3";
?>
What id like to do is when the thumbnails are displayed instead of just having a next and back buton have the page numbers at the bottom e.g. 1 2 3 4 etc etc, any quick and easy solutions?
Define the max number of images to show per page, then find the total number of images that are to be shown. Divide this number by the max number to be shown per page and round it up to the next whole number using ceil() so:
Then of course you need to grab $_GET[p] from the url and check it and edit the query to select what images need to be shown. For this code to work properly you should use $page to hold the value of $_GET[p], but as i said, you need to check that value for XSS and to make sure its a valid page - if not set it to 1.