|
|
|
|
![]() ![]() |
Nov 25 2007, 09:46 PM
Post
#1
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 11 Joined: 28-October 07 Member No.: 52,165 |
how to display 10 messages per page?
CODE <?php include("config/config.inc.php"); include("config/dbcon.php"); include("checksession.php"); if(isset($_POST['action'])){ $gname = $_POST['gname']; $gemail = $_POST['mail']; $gmsg = $_POST['gmsg']; $date = date("m.d.y"); $sql = "insert into tblguestbook "; $sql .= "(guestname, guestemail, guestmessage, guestdate)"; $sql .=" values('$gname','$gemail','$gmsg','$date')"; mysql_query($sql); } ?> <html> <head><title>My Guestbook</title> <link href="styles/style.css" rel="stylesheet" /> <script language="javascript" src="includes/validate.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"> <!-- body { background-color: #000000; } --> </style></head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="17%"> </td> <td width="83%" valign="bottom" > </td> </tr> </table> <form name = "form1" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" onSubmit="return validateForm(form1)"> <p class="fontSubTitle">Sign to Guestbook</p> <p class="fontSubTitle"><span class="fontText">Name: </span> <input type="text" name="gname"> <br> <span class="fontText">Email:</span> <input name="mail" type="text" id="mail"> <br> <span class="fontText">Message:</span> <textarea cols="35" rows="6" name="gmsg"></textarea> </p> <p class="fontSubTitle"> <input type="submit" value="Send" name="action"> <input name="reset" type="reset" value="Clear"> <br> </p> </form> <p> <?php $results = mysql_query("select * from tblguestbook order by guestid desc"); while($data = mysql_fetch_object($results)){ echo "<table width=\"500\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" class=\"borderThin\" >"; echo " <tr>\n"; echo "<td class=\"fontTextTwo\" align=\"left\" width=\"60%\">name: "; echo "<a href=\"mailto:".$data->guestemail."\" class=\"b\">".$data->guestname."</a>"; echo "</td>\n"; echo "<td class=\"fontTextTwo\" align=\"right\" width=\"40%\">dated posted: ".$data->guestdate."</td>\n"; echo " </tr>\n"; echo "<tr>\n"; echo " <td colspan=\"2\" class=\"fontText\" align=\"left\">".$data->guestmessage."</td>\n"; echo " </tr>\n"; echo "</table><br>"; } ?> </p> </body> </html> <?php mysql_close($dbh); ?> any help would be appreciated |
|
|
|
Nov 25 2007, 11:39 PM
Post
#2
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 3,874 Joined: 24-July 05 From: In Trouble Again... still? Member No.: 9,787 ![]() |
Google php pagination script
here is a link to Code Walkers. They have pretty solid scripts. http://www.codewalkers.com/c/a/Link-Farm-Code/Pagination/ |
|
|
|
Nov 26 2007, 01:52 AM
Post
#3
|
|
|
Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 974 Joined: 25-September 05 From: The dungeon deep below the foundation of trap17 Member No.: 12,251 |
I won't be as vague as grampa Jim was... Basically you'll want to add this bit of code to your sql query:
CODE $results = mysql_query("select * from tblguestbook order by guestid desc LIMIT ".($rowsperpage*(is_numeric($_GET['page'])?($_GET['page']-1):0)).", ".($rowsperpage*(is_numeric($_GET['page'])?$_GET['page']:1)).";"); And then at the beginning define the variable "$rowsperpage" CODE $rowsperpage=5; |
|
|
|
Nov 27 2007, 09:35 AM
Post
#4
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 11 Joined: 28-October 07 Member No.: 52,165 |
I won't be as vague as grampa Jim was... Basically you'll want to add this bit of code to your sql query: CODE $results = mysql_query("select * from tblguestbook order by guestid desc LIMIT ".($rowsperpage*(is_numeric($_GET['page'])?($_GET['page']-1):0)).", ".($rowsperpage*(is_numeric($_GET['page'])?$_GET['page']:1)).";"); And then at the beginning define the variable "$rowsperpage" CODE $rowsperpage=5; where will I put $rowsperpage=5; ? before include("config/config.inc.php"); ? |
|
|
|
Nov 27 2007, 02:42 PM
Post
#5
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 102 Joined: 13-October 07 Member No.: 51,530 |
put it before you use it.
This post has been edited by pop: Nov 27 2007, 02:42 PM |
|
|
|
Nov 27 2007, 06:34 PM
Post
#6
|
|
|
Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 974 Joined: 25-September 05 From: The dungeon deep below the foundation of trap17 Member No.: 12,251 |
Yeah anywhere before that sql query i told you to change is fine, but if I were you I'd put it at the begining of the file just incase you wanted to change how many rows per page are displayed quickly.
|
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 24th July 2008 - 05:17 AM |