madddidley
05-16-2004, 05:58 PM
Does anyone know where I could find a script that creates a new page for my guestbook after there are 20 posts on the page.
www.madddidley.com
www.madddidley.com
|
Click to See Complete Forum and Search --> : 20 posts per page madddidley 05-16-2004, 05:58 PM Does anyone know where I could find a script that creates a new page for my guestbook after there are 20 posts on the page. www.madddidley.com Conor 05-16-2004, 06:10 PM try searching google for pagination, should come up with what you need ShrineDesigns 05-17-2004, 01:19 AM if you are using mysql (or similar database) to store your guest book entries in, you could do something like this:<?php $per_page = 20; function pg() { return (isset($_GET['pg'])) ? $_GET['pg'] : 1; } $link_id = mysql_connect($server, $username, $password); mysql_select_db($database, $link_id); $result = mysql_query("SELECT * FROM `table` LIMIT ".(pg() - 1) * $per_page.", $per_page", $link_id); while($row = mysql_fetch_array($result, MYSQL_NUM)) { //process each row... } ?> madddidley 05-19-2004, 12:26 PM Would I put that function after the piece of code that actually adds it to the database? www.madddidley.com ShrineDesigns 05-19-2004, 09:42 PM a function must exist before you can use it Nevermore 05-20-2004, 01:13 AM Since PHP parses the file first, you should be able to put functions anywhere in the file and still reference them. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |