Jump to content

why it gives me wrong results ?


Rommeo

Recommended Posts

in my table datas are like :

1

2

3

4

 

print_page(0,2) gives me the result :

1

2

 

which is correct

print_page(1,2) gives me the result :

2

3

 

which is wrong

print_page(2,2) gives me the result :

3

4

which is wrong..

it includes the last data of previous query always.. 

i want it like :

 

page0 : 1,2

page1 : 3,4

 

my print_page function is like :

<?php 
print_page($num1, $num2) 
query = "......................ASC LIMIT ".$num1.",".$num2;
.
.
?>

 

any ideas what should i do ?

Link to comment
Share on other sites

That's how SQL LIMIT clause works. First number indicates on which ROW to start, second how many rows to retrieve. To have paging, you would need to:

function print_page($num1, $num2) {
query = "......................ASC LIMIT ".($num1 - 1) * $num2.",".$num2;
...
}

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.