ItsWesYo Posted July 9, 2007 Share Posted July 9, 2007 I have seen several PHP pagination tutorials and such... but none seem to "fit" in with this: <?php $host = "localhost"; $user = "xxxx"; $pass = "xxxx"; $db = "xxxx"; mysql_connect($host, $user, $pass) OR die ("Guestbook is temporarily offline."); mysql_select_db($db) OR die("Guestbook is temporarily offline."); $name = stripslashes($_POST['txtName']); $message = stripslashes($_POST['txtMessage']); if (!isset($_POST['txtName'])) { $query = "SELECT id, name, message, DATE_FORMAT(date,'%m/%d/%y') as newdate FROM guests ORDER BY id DESC"; $result = mysql_query($query); while ($row = mysql_fetch_object($result)) { ?> <b>#<?php echo $row->id; ?> - Posted by <?php echo $row->name; ?> on <?php echo $row->newdate; ?></b><br> <?php echo $row->message; ?><br><br> <?php } ?> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> <b>Name:</b><br> <input type='text' name='txtName' class='other'><br><br> <b>Message:</b><br> <textarea name='txtMessage' class='other'></textarea><br><br> <input type='submit' value='Add' class='other'> </form> <?php } else { // Adds the new entry to the database $query = "INSERT INTO guests SET message='$message', name='$name', date=NOW()"; $result = mysql_query($query); // Takes us back to the entries $ref = $_SERVER['HTTP_REFERER']; header ("Location: $ref"); } ?> Help? Quote Link to comment Share on other sites More sharing options...
chronister Posted July 9, 2007 Share Posted July 9, 2007 That is about as clear as mud. A little more detail as to what your trying to accomplish would be helpful. I assume that your wanting pagination on this section of code... if (!isset($_POST['txtName'])) { $query = "SELECT id, name, message, DATE_FORMAT(date,'%m/%d/%y') as newdate FROM guests ORDER BY id DESC"; $result = mysql_query($query); while ($row = mysql_fetch_object($result)) { Why do you say that the tutorials don't "fit" in with this code? Quote Link to comment 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.