DanielHardy Posted July 29, 2009 Share Posted July 29, 2009 Please view my following code. How would I go about adding pagination to my results with 5 results shown and then next and previous links. Iknow i need a counter and a while loop but I am still unsure about how to achieve this. <?php $guestbook = "messages.txt"; if (isset($_POST['button'])) { if (!empty($_POST['name']) && !empty($_POST['message'])) { $badSearch = array("@", "."); $goodSearch = array(" @ ", " . "); $string .= "<b>" . $_POST['name'] . " "; $string .= str_replace($badSearch, $goodSearch, $_POST['email']) . "</b>\n"; $string .= "<font color=#2766c5>" . $_POST['message'] . "</font>\n<hr>"; $file = fopen($guestbook, "a"); fwrite($file, nl2br(strip_tags($string, "<b><hr><font>"))); fclose($file); echo '<script>alert("Your comment has been added ")</script>'; } else { echo '<script>alert("Please fill out the whole form")</script>'; } } $readfile = fopen($guestbook, "r"); echo @fread($readfile, filesize($guestbook)); fclose($readfile); ?> Any help is greatly appreciated Thanks Dan Link to comment https://forums.phpfreaks.com/topic/167988-pagination-how-to/ Share on other sites More sharing options...
bruce080 Posted July 29, 2009 Share Posted July 29, 2009 This page was helpful to me. http://www.tonymarston.net/php-mysql/pagination.html Link to comment https://forums.phpfreaks.com/topic/167988-pagination-how-to/#findComment-886028 Share on other sites More sharing options...
DanielHardy Posted July 29, 2009 Author Share Posted July 29, 2009 Thanks but I'm not using a database Link to comment https://forums.phpfreaks.com/topic/167988-pagination-how-to/#findComment-886031 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.