The_Anomaly Posted July 20, 2006 Share Posted July 20, 2006 i have everything pretty much working but its displaying everything not just 5 at a time as i would like it to. I cant seem to find whats wrong. when i click the 1,2,3 links the page in the address bar says it has changed but all fields are still the same. Wanna take a look :)[code]<?php require_once('Connections/nwodb.php'); @mysql_select_db("nwo") or die("ERROR--CAN'T CONNECT TO DB"); $limit = 5; $query_Recordset1 = "SELECT * FROM person ORDER BY LastName ASC"; $result_count = mysql_query($query_Recordset1); $totalrows = mysql_num_rows($result_count); if(empty($page)) { $page = 1; } $limitvalue = $page * $limit - ($limit); //$query_Recordset1 = "SELECT * FROM person ORDER BY LastName ASC"; //$result = mysql_query($query) or die("Error: " . mysql_error()); $Recordset1 = mysql_query($query_Recordset1, $nwodb) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); if(mysql_num_rows($Recordset1) == 0) { echo("Nothing to Display!"); } $bgcolor = "#E0E0E0"; // light gray echo("<table>"); echo("<tr><td>"); echo("Member_ID"); echo("</td><td>"); echo("Last Name"); echo("</td><td>"); echo("First Name"); echo("</td></tr>"); while($row_Recordset1 = mysql_fetch_array($Recordset1)) { if ($bgcolor == "#E0E0E0") { $bgcolor = "#FFFFFF"; }else { $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor."><td width=\"20%\">"); echo ($row_Recordset1["Person_ID"]); echo ("</td><td width=\"40%\">"); echo($row_Recordset1["LastName"]); echo ("</td><td>"); echo($row_Recordset1["FirstName"]); echo("</td></tr>"); } echo("</table>"); //shows the previous # entries link if($page != 1){ $pageprev = $page--; echo("<a href=\"pagation.php=$pageprev\">PREV".$limit."</a> "); }else { echo("PREV ".$limit." "); } //shows the number of pages that can be selected from $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++) { if($i == $page) { echo($i." "); }else { echo("<a href=\"pagation.php?page=$i\">$i</a> "); } } //shows the next # enties link if(($totalrows % $limit) != 0) { if($i == $page){ echo($i." "); }else { echo("<a href=\"pagation.php?page=$i\">$i</a> "); } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"pagation.php?page=$pagenext\">NEXT ".$limit."</a>"); }else{ echo("NEXT ".$limit); } mysql_free_result($Recordset1); ?> [/code]I know its sloppy right now :| Quote Link to comment https://forums.phpfreaks.com/topic/15100-stuck-on-pagation/ Share on other sites More sharing options...
redarrow Posted July 20, 2006 Share Posted July 20, 2006 take a look at this and change whats needed okgood luck[code]<?//add databaseif(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } $max_results = 1; $from = (($page * $max_results) - $max_results); $query="select * from messages_copied LIMIT $from, $max_results";$result=mysql_query($query);while($record=mysql_fetch_assoc($result)){echo"<table align='center' width='300'border='4' bordercolor='black'><td align='left'><b>Members Id:<font color='red'><br>".$record["sent_id"]."</font><br> User Name: <font color='red'><br>".$record["members_name"]."</font><br>Sent Time: <font color='red'><br>".$record["time"]."</font> <br> Sent Date <font color='red'><br>".$record["date"]."</font> </b></td><td align='center' valign='top'><b>Members Message <font color='red'>$page</font><b><br><br><b><div align='left'><textarea col='7' rows='7'style='color: white; background-color: #A0C0F0'>".$record["message"]."</textarea></td></b></div><table>";echo "<table align='center' width='300'border='4' bordercolor='black'><td align='center'><b>";$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM messages_copied "),0); $total_pages = ceil($total_results / $max_results); if($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"></a>"; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\"></a>";} }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15100-stuck-on-pagation/#findComment-60828 Share on other sites More sharing options...
The_Anomaly Posted July 20, 2006 Author Share Posted July 20, 2006 Thats seems to work fine, but when i change it to display more than 1 item the page is a blank white. Quote Link to comment https://forums.phpfreaks.com/topic/15100-stuck-on-pagation/#findComment-60965 Share on other sites More sharing options...
The_Anomaly Posted July 20, 2006 Author Share Posted July 20, 2006 anyone? :( Quote Link to comment https://forums.phpfreaks.com/topic/15100-stuck-on-pagation/#findComment-61250 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.