matthew798 Posted September 9, 2008 Share Posted September 9, 2008 Hello again. How would i set up a pagination that displays only 5 rows? <?php $counter = 5; mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); $result = mysql_query("SELECT * FROM news ORDER BY id DESC") or die(mysql_error()); echo "<table border=0 width=696>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { echo "<tr><td><span class='title'>"; echo $row['title']; echo "</span></td></tr><tr><td><span class='date'>"; echo $row['date']; echo "</span></td></tr><tr><td><hr class='hrnews'></td></tr><tr><td><span class='body'>"; echo $row['body']; echo "</span></td></tr>"; } echo "</table>"; ?> Link to comment https://forums.phpfreaks.com/topic/123532-solved-pagination/ Share on other sites More sharing options...
matthew798 Posted September 9, 2008 Author Share Posted September 9, 2008 lol fixed it myself by addin "LIMIT 5" Link to comment https://forums.phpfreaks.com/topic/123532-solved-pagination/#findComment-637994 Share on other sites More sharing options...
gbunny Posted September 9, 2008 Share Posted September 9, 2008 lol I was just getting ready to respond with the limit 5 part. Something I like to do when setting up pages like that is actually pull 1 extra row from the database and use that extra row to determine whether or not i need to put the next button on the page or not. There's probably a better way to do this, but that works for me Link to comment https://forums.phpfreaks.com/topic/123532-solved-pagination/#findComment-637997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.