ابشر أخوي تفضل هذا الكود على السريع
كود PHP:
<html dir=rtl>
<?php
echo'
<table border="0" cellpadding="5" cellspacing="5" width="100%" dir="rtl">
<tr>';
$maindir = "images"; // مجلد الصور
$mydir = opendir($maindir) ;
$limit = 34; // عد الصور في كل صفحة
$offset = ((int)$_GET['offset']) ? $_GET['offset'] : 0;
$files = array();
$exclude = array( ".", "..", "index.php",".htaccess","guarantee.gif") ;
$count=0;
while($fn = readdir($mydir)){
if (!in_array($fn, $exclude)){
$files[] = $fn;;
}
}
closedir($mydir);
sort($files);
$newICounter = (($offset + $limit) <= sizeof($files)) ? ($offset + $limit) : sizeof($files);
for($i=$offset;$i<=$newICounter;$i++) {
?>
<td align=center width="%100" dir=rtl valign="top">
<img src="images/<?php print $files[$i]; ?>" align="absmiddle" border="0">
</td>
<?
$count++;
if($count==7){ // عدد الصور في كل عمود أفقي
echo'</tr><tr>';
$count=0;
}
}
echo'</tr>';
echo'</table>';
freddyShowNav($offset,$limit,sizeof($files),"");
function freddyShowNav($offset, $limit, $totalnum, $query) {
global $PHP_SELF;
if ($totalnum > $limit) {
$pages = intval($totalnum/$limit);
if ($totalnum%$limit) $pages++;
if (($offset + $limit) > $totalnum) {
$lastnum = $totalnum;
}
else {
$lastnum = ($offset + $limit);
}
?>
<table cellpadding="4"><tr><td>الصفحات </td>
<?php
for ($i=1; $i <= $pages; $i++) {
$newoffset=$limit*($i-1);
if ($newoffset != $offset) {
?>
<td>
<a href="<?php print $PHP_SELF; ?>?offset=<?php print $newoffset; ?><?php print $query; ?>"><?php print $i; ?>
</a>
</td>
<?php
}
else {
?>
<td><?php print $i; ?></td>
<?php
}
}
?>
</tr></table>
<?php
}
return;
}
echo $page;
?>
بس لا تنسانا عند طرح المفاجئه :nice:
مع تحياتي أخوك
عامر الصيعري