i founds tuts on how to limit number of files/images to show on a page and make a next page link for databases, but how can i make it to limit the # of images per page when the images are in a folder?
pagination
Started by venomsnake, Oct 02 2005 10:43 AM
6 replies to this topic
#1
Posted 02 October 2005 - 10:43 AM
#2
Posted 02 October 2005 - 10:44 PM
pagination was one of the most complicated things i learned for php and now you just made it even more complicated..now i'll have to test things out for this
#3
Posted 03 October 2005 - 01:11 AM
PM me or something and I'll make it for you
#4
Posted 04 October 2005 - 12:42 PM
Try using the SQL - LIMIT You can Limit 0, 30 Then LIMIT 31,60 And so on
#5
Posted 04 October 2005 - 01:40 PM
He doesn't want to use SQL, He said he wants to have it browse a directory ie: images/
And say there are 30 in there, and he wants 10 per page, 3 pages, 10 on each.
And say there are 30 in there, and he wants 10 per page, 3 pages, 10 on each.
#6
Posted 06 October 2005 - 10:05 AM
Hi, I wrote a script for just this purpose. Hope it helps
Cheers
SpikeZ
<?php
function pageDirectory($dir){
$start = isset($_GET['start']) ? $_GET['start'] : 0;
# grab files from directory///
$files=array();
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && !is_dir($file)) {
$files[] = $file;
}
}
closedir($handle);
}
$dpp = 10;
$total = count($files);
$req= round($total/10);
for($i=$start; $i<=($start+$dpp)-1; $i++) {
if($i <=$total-1){
$fz = filesize('../i/hi_res/'.$files[$i]);
echo '<a href="download.php?im=../i/hi_res/'. $files[$i] .'">'. ($i+1) . ' » '. $files[$i] .'</a> ('
. format_size($fz) .
')<hr>';
}
}
echo '<a href="?action='.strtolower($area).'&start=0">First</a> | ';
for($x=0;$x<=$req-1; $x++) {
echo '<a href="?action='.strtolower($area).'&start='. ($x*10) . '">'. ($x+1) . '</a> | ';
}
echo '<a href="?action='.strtolower($area).'&start='. ($total-10) . '">Last</a> | ';
}//end function
/** use like this:
$dir = '/home';
pageDirectory($dir);
**/
?>
Cheers
SpikeZ
#7
Posted 09 October 2005 - 03:39 PM
awsome thanks
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
