Page indexer ??

thezone1

New Member
Messages
192
Reaction score
0
Points
0
Hi people i currently have a script that displays images from a directory on a page

PHP:
$path = "../../usr/{$user}/images/";
$dir_handle = @opendir($path) or die("Error could not list image directory");
while ($file = readdir($dir_handle)) 
{
   if($file!="." && $file!="..")
      echo "<img style=\"border:#FFF thin solid\" src=\"$dir$file\" height=\"55\" width=\"55\">";
}
closedir($dir_handle);

it works but now that users are starting to have more than 20 images in their directories my page design is suffering..

So does anyone know of a script that will after the image count has reached 10 start a new page ??
 

VPmase

New Member
Messages
914
Reaction score
0
Points
0
PHP:
$page = intval($_GET['pn']);
if($page <= 0){
$page = 1;
}
$startnum = $page * 10;
$endnum = $startnum + 10;
$path = "../../usr/{$user}/images/";
$dir_handle = @opendir($path) or die("Error could not list image directory");
while ($file = readdir($dir_handle)) 
{
if($startnum != $endnum){
   if($file!="." && $file!="..")
      echo "<img style=\"border:#FFF thin solid\" src=\"$dir$file\" height=\"55\" width=\"55\">";
$startnum ++
} else {
closedir($dir_handle);
}
echo "<a href=\"?pn=".$page-1."\">Previous 10</a> - ";
echo "<a href=\"?pn=".$page+1."\">Next10</a>";

Just a note: I suggest you use databases as you can store more info and you can keep all the files in a specific order but your preference.
 
Last edited:
Top