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
https://forums.phpfreaks.com/topic/198227-why-it-gives-me-wrong-results/
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;
...
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.