[英]PDO Pagination - link to previous/next page not correct
I just added php pagination to my website but I don't manage to link to the correct pages. 我只是在我的网站上添加了php分页,但是我没有设法链接到正确的页面。
Background information: 背景资料:
People can select a bike brand on the page "example.com/bikebrands.php". 人们可以在“ example.com/bikebrands.php”页面上选择自行车品牌。 So when they select "Bianchi", it opens the webpage "example.com/bikebrands/bianchi" with a list of all related news posts for that brand found in my database.
因此,当他们选择“ Bianchi”时,它将打开网页“ example.com/bikebrands/bianchi”,并在我的数据库中列出该品牌的所有相关新闻报道。
I had to set a target page to make the pagination work. 我必须设置目标页面才能使分页工作。 I chose "/bikebrands" but that's not correct.
我选择了“ / bikebrands”,但这是不正确的。 It should be:
它应该是:
$targetpage = "/bikebrands/**(echo row "bike brand" from database depending on the bike brand the visitor has selected)**?page=2";
So when someone opens: example.com/bikebrands/bianchi
and clicks "next", it should load example.com/bikebrands/bianchi?page=2
因此,当有人打开:
example.com/bikebrands/bianchi
并单击“下一步”时,它应该加载example.com/bikebrands/bianchi?page=2
And when someone opens: example.com/bikebrands/trek
and clicks "next", it should load example.com/bikebrands/trek?page=2
当有人打开:
example.com/bikebrands/trek
并单击“下一步”时,它应该加载example.com/bikebrands/trek?page=2
The page example.com/bikebrands/bianchi?page=2
exists so there's no problem with the url itself, it's just that I don't manage to link to that page. 页面
example.com/bikebrands/bianchi?page=2
存在,因此url本身没有问题,只是我没有设法链接到该页面。
How can I achieve this? 我该如何实现?
假设品牌只是另一个参数,您是否无法使用$_GET['brand']
或给出的任何名称来检索它?
$targetpage = "/bikebrands/" . $GET['brand'] . "?page=" . $next;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.