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

C++ JAVA
Post Reply
User avatar
val4o0o0
Турист
Турист
Posts: 349
Joined: Tue Jun 23, 2009 8:17 pm

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

Post by val4o0o0 » Sun Oct 24, 2010 9:05 am

Code: Select all

<?php
$directory = opendir&#40;'../images/lightbox/'&#41;;
while &#40;$files = readdir&#40;$directory&#41;&#41;
&#123;
$file_array&#91;&#93; = $files;
&#125;
foreach &#40;$file_array as $files&#41;
&#123;
echo "";
if&#40;$files == ".." || $files == "."&#41;
&#123;
continue;
&#125;

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

&#125;
?> 
може ли някой да го страницира ?

kikoto
Нов
Нов
Posts: 81
Joined: Tue Mar 25, 2008 7:11 am

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

Post by kikoto » Sun Oct 24, 2010 3:42 pm

Code: Select all

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http&#58;//www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>

<html xmlns='http&#58;//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&#40;'../images/lightbox/'&#41;;
while &#40;$files = readdir&#40;$directory&#41;&#41;
&#123;
$file_array&#91;&#93; = $files;
&#125;
foreach &#40;$file_array as $files&#41;
&#123;
echo "";
if&#40;$files == ".." || $files == "."&#41;
&#123;
continue;
&#125;

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

&#125;
?>

</html>

User avatar
val4o0o0
Турист
Турист
Posts: 349
Joined: Tue Jun 23, 2009 8:17 pm

Post by val4o0o0 » Sun Oct 24, 2010 3:45 pm

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

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

Code: Select all

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

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

echo "<br /><br />Страници&#58; "; 
for &#40;$i=1;$i<=$stranici;$i++&#41; &#123; 
if &#40;$page != $i&#41; &#123; 
echo "<a class=\"typ1\" href=\"?page=$i\">$i</a> "; 
&#125; else &#123; 
echo "<a class=\"typ1noh\" style=\"color&#58; #ffffff\">$i</a> "; 
&#125; 
&#125; 
?>	

User avatar
val4o0o0
Турист
Турист
Posts: 349
Joined: Tue Jun 23, 2009 8:17 pm

Post by val4o0o0 » Tue Oct 26, 2010 10:53 am

up

Post Reply