странициране на този код

val4o0o0

Registered
Код:
<?php
$directory = opendir('../images/lightbox/');
while ($files = readdir($directory))
{
$file_array[] = $files;
}
foreach ($file_array as $files)
{
echo "";
if($files == ".." || $files == ".")
{
continue;
}

echo "<img src=\"../images/lightbox/$files\" alt=\"xx\" width=\"120\" height=\"120\" border=\"0\" />";
echo "<a href=\"admin_gallery_del.php?target=$files\">[X]</a>";
$file = "./".$files;

}
?>

може ли някой да го страницира ?
 
Код:
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>

<html xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <title>tcccc...</title>
    <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
    <meta http-equiv='content-style-type' content='text/css' />
  </head>
<?php
$directory = opendir('../images/lightbox/');
while ($files = readdir($directory))
{
$file_array[] = $files;
}
foreach ($file_array as $files)
{
echo "";
if($files == ".." || $files == ".")
{
continue;
}

echo "<img src=\"../images/lightbox/$files\" alt=\"xx\" width=\"120\" height=\"120\" border=\"0\" />";
echo "<a href=\"admin_gallery_del.php?target=$files\">[X]</a>";
$file = "./".$files;

}
?>

</html>
 
не си ме разбрал не искам такова странициране, 1,2,3,4 страници ? картинките са около 40 искарват се с този скрипт и искам да са на 2 реда по 4 картинки на ред.

ето за пример едно файлово странициране:

Код:
<?php 
// настройки // 
$pics_folder = "images/lightbox"; // в коя папка са картинките
$pics_per_page = 8; // по колко картинки на страница 
$pics_ex = array('jpg','jpeg','gif','png'); // кои файлове да зачита като картинки 
// настройки // 

$pics_folder = preg_replace('/[\/]+/', '/', preg_replace('/^[\/]+/', '', $pics_folder).'/'); 
function all_images() 
{ 
global $pics_folder, $pics_ex; 
$folders = array($pics_folder); 
$out_files = array(); 
while (count($folders)) 
{ 
foreach ($folders as $folder) 
{ 
array_shift($folders); 
$dir = opendir($folder); 
while ($file = readdir($dir)) 
{ 
if ($file != '.' && $file != '..') 
{ 
if (is_file($folder.$file) && in_array(strtolower(end(explode(".", $file))), $pics_ex)) 
{ 
$out_files[] = $folder.$file; 
} 
elseif (is_dir($folder.$file)) 
{ 
$folders[] = $folder.$file.'/'; 
} 
} 
} 
} 
} 
return $out_files; 
} 
$all_images = all_images(); 
$out_images = array(); 
foreach ($all_images as $image) 
{ 
$raz = explode("/", $image); 
for ($n=1;$n<=(substr_count($pics_folder, "/"));$n++) array_shift($raz); 
array_pop($raz);  
$out_images[] = $image; 
} 
$masiv = @array_chunk($out_images, $pics_per_page, true); 
$stranici = floor(count($out_images) / $pics_per_page); 
if ((count($out_images) % $pics_per_page) > 0) { $stranici++; } 
if (is_numeric($_GET['page']) && $_GET['page'] <= $stranici) { 
$page = $_GET['page']; 
} else { 
$page = 1; 
} 
$red = 1; 
foreach ($masiv[($page - 1)] as $pic) 
{ 
$razp = explode("/", $pic); 
for ($n=1;$n<=(substr_count($pics_folder, "/"));$n++) array_shift($razp); 
array_pop($razp); 
for ($i=0;$i<count($razp);$i++) 
{ 
$url = array(); 
for($i2=0;$i2<=$i;$i2++) 
{ 
$url[] = $razp[$i2]; 
}   
} 
echo "<a style=\"padding-left: 1px\" href=\"{$pic}\" rel=\"lightbox\"><img src=\"{$pic}\" width=\"120\" height=\"120\" border=\"0\" alt=\"gallery\" /></a> "; 
if ($red == floor(sqrt($pics_per_page))) { $red = 1; echo "\n"; } else { $red++; } 
} 

echo "<br /><br />Страници: "; 
for ($i=1;$i<=$stranici;$i++) { 
if ($page != $i) { 
echo "<a class=\"typ1\" href=\"?page=$i\">$i</a> "; 
} else { 
echo "<a class=\"typ1noh\" style=\"color: #ffffff\">$i</a> "; 
} 
} 
?>
 

Back
Горе