-6

可能重复:
PHP 和 MySQL 分页

我对如何向我的 mysql 查询添加分页有点困惑,因为我每次都在循环遍历结果并将它们添加到一个变量中:

$DBQuery3 = mysqli_query($dblink, "SELECT * FROM images WHERE project_id = '$FormProjectID'");

$ProjectContent ='';
                        while($row = mysqli_fetch_array($DBQuery3)) {
                            $DBImageID = $row['image_id'];
                            $DBProjectID = $row['project_id'];
                            $DBImageName = $row['image_name'];
                            $DBImageDescription = $row['image_description'];
                            $DBDateCreated = $row['date_created'];
                            $DBLinkToFile = $row['link_to_file'];
                            $DBLinkToThumb = $row['link_to_thumbnail'];
                            $DBGivenName = $row['given_name'];

                            //if the image was given a name by the user, display it
                            //otherwise display the generated name

                            if (strlen($DBGivenName) > 1) {
                                $FileName = $DBGivenName;
                            } else {
                                $FileName = $DBImageName;
                            }

                            $ProjectContent .= '
                                <a href="index.php?page=image&id='.$DBImageID.'"><img src="uploads/'.$DBLinkToThumb.'" width="150px" height="150px" alt="'.$FileName.'" title="'.$FileName.'"/></a>
                            ';

任何指向正确方向的人都将不胜感激。

4

1 回答 1

0

嗨,

试试用php分页脚本,网上有很多,随便找那些词。

例如: http: //www.coursesweb.net/php-mysql/pagination-class-script_s2可以对存储到数据库或数组中的数据进行分页。

于 2012-06-03T14:14:02.437 回答