Jump to content

Pagination link error


leon

Recommended Posts

Hello;

I am working on pagination and trying to adapt it to my website. But i encountered a problem when displaying to links to the pages.I mean;

(Prev 1 2 3 4 ... Next ) part...

[code]
for($page = 1; $page<= $maxpage; $page++){
        if($page == $currentpage){
            echo($page." ");
        }else{
            echo "<a href=\"$PHP_SELF?page=$page&product_id= (($rowsPerPage * ($page-1)) + 1)\">$page</a> ";
        }
}
[/code]

What I want to do here is that; I am on the first page and wanna go to the second page, When I click on (2) , I want to see (...php?page=2 &product_id=9) page.

I have a variable at the top. ($rowsPerPage=8). But when I hover on (2), the thing I see as a link is: ...php?page=2 &product_id= ((8 * (2-1)) + 1).

You know, if the product_id variable is defined, there is no problem. The correct page comes.
I can provide the whole code if requested
Thanks...

Link to comment
Share on other sites

spot the diffrence

good luck.



authors code
[code]
if(!isset($page)) $page = 0;

//mysql_query here to get $page_text

$pagearray=split("[NEXTPAGE]", $page_text);

echo "$page_text";

if($page != 0){
    $prevpage = $page - 1;
    echo "<a href="/link_to_previous_page">Previous Page</a>&nbsp;&nbsp;";
}

if($page < count($pagearray) -1) {
    $nextpage = $page + 1;
    echo "<a href="/link_to_next_page">Next Page</a>";
}

[/code]



your code
[code]


for($page = 1; $page<= $maxpage; $page++){
        if($page == $currentpage){
            echo($page." ");
        }else{
            echo "<a href=\"$PHP_SELF?page=$page&product_id= (($rowsPerPage * ($page-1)) + 1)\">$page</a> ";
        }
}

[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.