我是网页编码的新手,我遇到了问题......
现在我可以添加一个代码来列出和回显目录中的图像,用灯箱显示它们。
现在代码显示目录中的所有图像,每行 5 张图像,但没有限制......
我如何将代码更改为页面结果,例如:只有一行,每页 5 张图像。然后显示通常的“Page: 1, 2, 3 ... Next ...” 我真的不知道该怎么做...我一直在尝试很多事情都没有成功...
代码如下:
<?php 
$page = $_SERVER['PHP_SELF'];
// How many images per row
$maxCols = 5;
// Directory where the albums are stored
$base = "albums";
// Get album title
$get_album = $_GET['album'];
if (!$get_album)
{
    $handle = opendir($base);
    echo "<div id='albums' class='imageRow'>";
    while (($file = readdir($handle))!==FALSE)
    {       
        if (is_dir($base."/".$file) && $file != "." && $file != "..")
        {
            //$list []= $file;
            $img = $file.".jpg"; //Main image from each album.
            echo "<div class='image'><a href='$page?album=$file'><img src='thumbnails.php?img=$base/$img' alt='$file' /></a><div class='album'><i>$file</i></div></div>";
        }       
    }
    echo "</div>";
    closedir($handle);
    //$total = count($list);
}
else
{
    if (!is_dir($base."/".$get_album) || strstr($get_album,".")!=NULL || strstr($get_album,"/")!=NULL || strstr($get_album,"\\")!=NULL)
    {
        echo "Album doesn't exist.";
        echo "<p /><a href='$page'>Back to albums</a>";
    }
    else
    {
        $count = 0;
        $handle = opendir($base."/".$get_album);
        echo "<div id='images' class='imageRow'>";
        while (($file = readdir($handle)) !== FALSE)
        {
            if ($file != "." && $file !== "..")
            {
                echo "<div class='image'><a href='$base/$get_album/$file' rel='lightbox[1]' title='$file'><img src='thumbnails.php?img=$base/$get_album/$file' alt='$file' /></a></div>";
                $count++;
                if($count == $maxCols) 
                {
                    echo "</div>";
                    echo "<div id='images' class='imageRow'>";
                    $count = 0;
                }
                $list[] = $file; //Assign the images to a list to allow count.
            }
        }
        echo "</div>";
        closedir($handle);
        $total = count($list); //Total elements at the album.
        //echo "<a href='$page'>Back to albums</a>";
    }
}
?>
任何帮助都感激不尽!
提前谢谢了!!
