Mudsaf Posted July 31, 2012 Share Posted July 31, 2012 (edited) 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 July 31, 2012 by Mudsaf Link to comment Share on other sites More sharing options...
birbal Posted July 31, 2012 Share Posted July 31, 2012 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 More sharing options...
kanchatchai Posted July 31, 2012 Share Posted July 31, 2012 http://w3schools.invisionzone.com/index.php?showtopic=44425&view=findpost&p=247355My Pagination Function. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now