i have used a similar script on www.cougarimage.com before..
however, it is much easier if you use a database.
but my script does it as you want... so here's the script I used... not 100% mine, but it works.
<?
$incldir="thumbs/";
$pagenum=$QUERY_STRING;
if ( $pagenum == NULL ) {
$pagenum=1;
}
$realpage=$pagenum - 1;
$linecount=0;
$d2 = dir($incldir);
while($entry=$d2->read()) {
if ( $entry != "." && $entry != ".." && $entry != ".total" ) {
$linecount++;
}
}
$pagecount=$realpage * 10 + 1;
$endcount=$pagecount + 10;
$totalpages=floor($linecount / 10);
$rtotalpages=$linecount % 10;
if ( $rtotalpages >= 1 ) {
$totalpages++;
}
//line 30
$currcount=1;
$d2 = dir($incldir);
while($entry=$d2->read()) {
if ( $entry != "." && $entry != ".." ) {
if ( $currcount < $endcount && $currcount >= $pagecount )
{
echo "<a href=\"upload/${entry}\"><img src=\"thumbs/${entry}\" border=0></a> ";
}
$currcount++;
}
}
echo "<br><Br>";
$back=$pagenum - 1;
$next=$pagenum + 1;
if ( $back < "1" ) {
echo " ";
} else {
echo "<A href=\"".$PHP_SELF."?$back\"><<</a>";
echo " ";
}
$totalpagecount=1;
while ( $totalpagecount <= $totalpages ) {
if ( $totalpagecount == $pagenum ) {
echo "<b>$totalpagecount</b> ";
} else {
echo "<a href=\"".$PHP_SELF."?$totalpagecount\">$totalpagecount</a> ";
}
$totalpagecount++;
}
if ( $next > $totalpages ) {
echo " ";
} else {
echo "<A href=\"".$PHP_SELF."?$next\">>></a>";
}
?>
I found the script somewhere (credit to whomever made it 😉 ) and I added a few things here and there.. and fixed a few bugs in it. works great now... however, with this it is important that you do not put the pictures in a table.
if you havea ny problems with the $PHP_SELF, just change it to yourpage.php instead.
also, i used a variation of this script to insert my images on cougarimage.com into a database and it made everything alot easier... so that's my suggestion to you if you know database's
good luck