Jump to content

Problem with Previous & Next page


Mudsaf

Recommended Posts

Im trying to make page that allows to see "comments" 5 at time and if you press next it shows next 5 comments and previous shows previous 5 comments. My code is only working 1 time per way so i get like next 5 comments (this only works once) and previous 5 comments (this only works once).

$val1 = 0;$val2 = 5; if (isset($_GET['next'])) {$val1 = $val1 + 5;}if (isset($_GET['previous'])) {if ($val1 >= 5) {$val1 = $val1 - 5;} }$query = "SELECT * FROM *TABLE* WHERE *COLUMN* = '{$_GET['id']}' ORDER BY *COLUMN* DESC LIMIT " . $val1 . ", " . $val2; while ($row2 = mysql_fetch_array($result2)) {echo "Published: " . $row2['*COLUMN'];echo "<textarea name=\"text\" cols=\"70\" rows=\"5\" readonly id=\"text\">" . $row2['*COLUMN*t'] . "</textarea>";}  

So im wondering is it possible to get that working the way i want. (I dont want to use POST method to get another page)

Edited by Mudsaf
Link to comment
Share on other sites

if (isset($_GET['next'])) { $val1 = $val1 + 5; }
this will always be $val=10 no matter what value passed with 'next'. you have to keep track of page number. and increase/decrease the limit offset according to current page. you can make next/previous link dynamically once you know the current page number.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...