简体   繁体   中英

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.

Background information:

People can select a bike brand on the page "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.

I had to set a target page to make the pagination work. I chose "/bikebrands" but that's not correct. 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

And when someone opens: example.com/bikebrands/trek and clicks "next", it should load 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.

How can I achieve this?

假设品牌只是另一个参数,您是否无法使用$_GET['brand']或给出的任何名称来检索它?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM