PHP& MySQL分页更新帮助 [英] PHP & MySQL Pagination Update Help

查看:70
本文介绍了PHP& MySQL分页更新帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我在网页上更新了分页以来已经有一段时间了,当搜索结果很长时,我试图将FirstLast链接以及...链接添加到我的分页中.例如,我正在尝试在以下示例中实现以下目标.有人可以帮我修复我的代码,以便更新我的网站.谢谢

Its been a while since I updated my pagination on my web page and I'm trying to add First and Last Links to my pagination as well as the ... when the search results are to long. For example I'm trying to achieve the following in the example below. Can some one help me fix my code so I can update my site. Thanks

First Previous 1 2 3 4 5 6 7 ... 199 200 Next Last 

我目前使用我的代码显示以下内容.

I currently have the following displayed using my code.

Previous 1 2 3 4 5 6 7 Next

这是我的分页代码中显示链接的部分.

Here is the part of my pagination code that displays the links.

if ($pages > 1) {

    echo '<br /><p>';

    $current_page = ($start/$display) + 1;

    if ($current_page != 1) {
        echo '<a href="index.php?s=' . ($start - $display) . '&p=' . $pages . '">Previous</a> ';
    }

    for ($i = 1; $i <= $pages; $i++) {
        if ($i != $current_page) {
            echo '<a href="index.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> ';
        } else {
            echo '<span>' . $i . '</span> ';
        }
    } 

    if ($current_page != $pages) {
        echo '<a href="index.php?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>';
    }

    echo '</p>';

}

推荐答案

您唯一需要的教程. http://www.php-mysql- tutorial.com/wikis/php-tutorial/paging-using-php.aspx

The only tutorial you need. http://www.php-mysql-tutorial.com/wikis/php-tutorial/paging-using-php.aspx

对我有用.该教程还有第二部分,但是您不需要它.它告诉您如何修改现有代码.

It worked for me. There is also a part 2 to that tutorial but you won't need it. It tells you how to modify your existing code.

这篇关于PHP&amp; MySQL分页更新帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆