Version: 4.0
Type: Full Script
Category: HTML
License: GNU General Public License
Description: This script displays the records in a resultset into pages. It also displays the current page as a text, rather than a link.
<?php include("connection.php"); echo("<font color=#7C80AA>Multiple Records:</font>"); echo("<br><br><br>"); $iPageSize = 5; static $iRowStart=0; static $iNext=0; static $iPrev=0; static $pages=0; $iRowStart = $iCurrentRow; $iNext = $iCurrentRow; $strSQL = "SELECT * FROM user ORDER BY userID DESC"; $result = mysql_query($strSQL) OR DIE("Error retrieving records."); $iRecordCount = mysql_num_rows($result); $pages = ($iRecordCount/$iPageSize); if($iRecordCount%$iPageSize) $pages++; $iRecShown = 0; echo("<table width=50% border=0>"); for($i = $iRowStart;$iRecShown < $iPageSize,($iRowStart+$iRecShown)<($iRowStart+$iPageSize); $i++,$iRecShown++) { @ mysql_data_seek($result,$i); $CurrentRec = mysql_fetch_array($result); if($CurrentRec) { echo("<tr>"); echo("<td width=20%>"); echo("<b>MemberID:</b>"); echo("</td>"); echo("<td width=10%>"); echo($CurrentRec["userID"]); echo("</td>"); echo("<td width=30%>"); echo("<b>Member Name:</b>"); echo("</td>"); echo("<td width=30%>"); echo($CurrentRec["usernick"]); echo("</td>"); echo("</tr>"); } } echo("</table>"); echo("<br><br>"); $iPrev = ($iNext - $iPageSize); $iNext = ($iRowStart + $iPageSize); echo("<table width=100% border=0 cellspacing=0 cellpadding=0>"); echo("<tr>"); echo("<td width=33% align=left>"); if($iRowStart > 1) echo("<a href=$PHP_SELF?iCurrentRow=$iPrev><b><< Previous</b></a>"); echo("</td>"); echo("<td width=33% align=center>"); echo("<b>Pages: </b>"); for($i=1;$i<=$pages;$i++) { if($i==1) $pageID = 0; else $pageID = $pageID + $iPageSize; //Displays the current page as a text. if($pageID!=$iCurrentRow) echo("<a href=$PHP_SELF?iCurrentRow=$pageID>$i</a> "); else echo($i . " "); } echo ("</td>"); echo("<td width=33% align=right>"); if($iNext < $iRecordCount) echo("<font align=left><a href=$PHP_SELF?iCurrentRow=$iNext><b>Next >></b></a>"); echo("</td>"); echo("</tr>"); echo("</table>"); mysql_free_result($result); ?>