【问题标题】:PDO Pagination - link to previous/next page not correctPDO 分页 - 上一页/下一页的链接不正确
【发布时间】:2014-06-29 14:52:54
【问题描述】:

我刚刚在我的网站上添加了 php 分页,但我无法链接到正确的页面。

背景信息:

人们可以在“example.com/bikebrands.php”页面上选择自行车品牌。 因此,当他们选择“Bianchi”时,它会打开网页“example.com/bikebrands/bianchi”,其中列出了在我的数据库中找到的该品牌的所有相关新闻帖子。

我必须设置一个目标页面才能使分页工作。我选择了“/bikebrands”,但这不正确。 应该是:

$targetpage = "/bikebrands/**(echo row "bike brand" from database depending on the bike brand the visitor has selected)**?page=2";

所以当有人打开时: example.com/bikebrands/bianchi 并点击“下一步”,它应该会加载example.com/bikebrands/bianchi?page=2

当有人打开时: example.com/bikebrands/trek 并点击“下一步”,它应该会加载 example.com/bikebrands/trek?page=2

页面example.com/bikebrands/bianchi?page=2存在,所以url本身没有问题,只是我没有设法链接到那个页面。

我怎样才能做到这一点?

【问题讨论】:

    标签: php pdo hyperlink pagination target


    【解决方案1】:

    假设品牌只是另一个参数,您不能使用$_GET['brand'] 或任何名称检索它吗?

    $targetpage = "/bikebrands/" . $GET['brand'] . "?page=" . $next;
    

    【讨论】:

    • 就这么简单。谢谢!
    猜你喜欢
    • 2021-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-09
    • 2013-08-26
    • 2014-09-26
    • 2013-12-18
    • 1970-01-01
    相关资源
    最近更新 更多