nathanmaxsonadil Posted September 6, 2007 Share Posted September 6, 2007 I was wondering if there was something like wordpress's next entries & previous entries.... Quote Link to comment https://forums.phpfreaks.com/topic/68274-solved-next-entries-previous-entries/ Share on other sites More sharing options...
nathanmaxsonadil Posted September 6, 2007 Author Share Posted September 6, 2007 I already have this code but don't know how to make it so that it show's a next or previous link... to set the varible's if(isset($_GET['start'])){ $limit = $_GET['start']; $endlimit = $_GET['start'] + 100; }else { $limit = 0; $endlimit = 100; } the query $sql = mysql_query("SELECT * FROM yourtable ORDER BY id LIMIT {$limit},{$endlimit}") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/68274-solved-next-entries-previous-entries/#findComment-343283 Share on other sites More sharing options...
Wuhtzu Posted September 6, 2007 Share Posted September 6, 2007 Read these to tutorials (or just one of them) http://www.phpfreaks.com/tutorials/73/0.php http://www.phpfreaks.com/tutorials/43/0.php Quote Link to comment https://forums.phpfreaks.com/topic/68274-solved-next-entries-previous-entries/#findComment-343286 Share on other sites More sharing options...
nathanmaxsonadil Posted September 6, 2007 Author Share Posted September 6, 2007 I can't understand the tutorial's very much so I tried a bit more and here are my results... set the varible's if(isset($_GET['start'])){ $limit = $_GET['start']; $endlimit = $_GET['start'] + 100; $morepages = $_GET['start'] + 100; $lesspages = $_GET['start'] - 100; }else { $limit = 0; $endlimit = 100; $morepages = 200; $lesspages = 0; } the query $sql1 = mysql_query("SELECT * FROM youtable ORDER BY id LIMIT {$limit},{$endlimit}") or die(mysql_error()); $sql2 = mysql_query("SELECT * FROM youtable ORDER BY id") or die(mysql_error()); more pages and previous page links if(mysql_num_rows($sql4) > $limit) { echo "<p><a href='yourpage.php?start={$morepages}'>next page</a></p>"; } if($limit > 100) { echo "<p><a href='yourpage.php?start={$lesspages}'>previous page</a></p>"; } Quote Link to comment https://forums.phpfreaks.com/topic/68274-solved-next-entries-previous-entries/#findComment-343312 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.