TecTao Posted October 19, 2007 Share Posted October 19, 2007 I'm looking for an easy to understand, easy to implement pagination script for PHP. I've used a script by Evolt before but have run into some problems. My main challenge this time is that it needs to join two tables and paginate the the results. Any suggested sites with open source would be great. Thanks, m Quote Link to comment https://forums.phpfreaks.com/topic/73937-pagination-script-needed/ Share on other sites More sharing options...
steve448 Posted October 19, 2007 Share Posted October 19, 2007 There are 10 different pagination scripts listed in phpfreaks code section http://www.phpfreaks.com/quickcode_cats/33/Pagination.php Quote Link to comment https://forums.phpfreaks.com/topic/73937-pagination-script-needed/#findComment-373080 Share on other sites More sharing options...
DarkPrince2005 Posted October 19, 2007 Share Posted October 19, 2007 <?php mysql_connect("localhost","root",""); mysql_select_db("dbs"); echo "<html><head><title></title><link rel='stylesheet' href='stylesheet.css' type='text/css'> <style> a:link{font-family:'Verdana'; color:'#000000'; font-weight:700; text-decoration:none; } a:visited{font-family:'Verdana'; color:'#000000'; font-weight:700; text-decoration:None; } a:hover{font-family:'Verdana'; text-decoration:none; color:'#B37A04'; font-weight:700; } a:active{font-family:'Verdana'; color:'#000000'; font-weight:700; } </style></head><body bgcolor='#FDCC67' topmargin='0' bottommargin='0' leftmargin='0' rightmargin='0'> <center><table width='100%' height='100%' cellpadding='0' cellspacing='0' border='0'> <tr><td valign='top' width='140' background='graphics/nav.gif'><br><center><font size=3>MENU</font><br><img src='graphics/NavSeparator.gif' width=130></center><br> <font size='2'><a href='home.html'> <img src='graphics/NavBullet.gif' border=0> Home</a></font><br><br> <font size='2'><a href='view.php'> <img src='graphics/NavBullet.gif' border=0> View Records</a></font><br><br> <font size='2'><a href='add.html'> <img src='graphics/NavBullet.gif' border=0> Add Record</a></font><br><br> <font size='2'><a href='edit.html'> <img src='graphics/NavBullet.gif' border=0> Edit Record</a></font><br><br> <font size='2'><a href='delete.html'> <img src='graphics/NavBullet.gif' border=0> Delete Record</a></font><br><br> <font size='2'><a href='datereport.html'> <img src='graphics/NavBullet.gif' border=0> View Report</a></font><br><br> <font size='2'><a href='q.html'> <img src='graphics/NavBullet.gif' border=0> Query Report</a></font><br><br> <font size='2'><a href='search1.html'> <img src='graphics/NavBullet.gif' border=0> Search</a></font><br><br><br><center><img src='graphics/NavSeparator.gif' width=130></center><br></td><td valign='top' align='center'><table><tr> <td align='right' valign='top'><form action='search2.php' method='post'><b>Search by Persal Number or Last Name:</b> <input type='text' name='search'> <input type='submit' value='Search'></form></td></tr> <tr><td align='center' valign='top'><h1>View Disciplinary Records</h1></td></tr> <tr><td align='center' valign='top'><center><font size=2 color='#ffffff'>"; // If current page number, use it // if not, set one! if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } // Define the number of results per page $max_results =1; // Figure out the limit for the query based // on the current page number. $from = (($page * $max_results) - $max_results); // Perform MySQL query on only the current page number's results $sql = mysql_query("SELECT * FROM dis LIMIT $from, $max_results"); // Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM dis"),0); // Figure out the total number of pages. Always round up using ceil() $total_pages = ceil($total_results / $max_results); // Build Page Number Hyperlinks // Build Previous Link if($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } // Build Next Link if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\"> Next>></a>"; }while($row = mysql_fetch_array($sql)){ // Build your formatted results here. echo "</font><center><form> <table cellpadding='0' border='0' cellspacing='0'><tr> <td valign='top'><table width='300'> <tr><td><b>File Ref</td><td> </td> <td>$row[File_Ref]</td></tr> <tr><td><b>Firstname</td><td> </td> <td>$row[Employee_Firstname]</td></tr> <tr><td><b>Lastname</td><td> </td> <td>$row[Employee_Lastname]</td></tr> <tr><td><b>Persal Number</td><td> </td> <td>$row[Persal_Number]</td></tr> <tr><td><b>Occupation</td><td> </td> <td>$row[Occupation]</td</tr> <tr><td><b>Level</td><td> </td> <td>$row[Level]</td</tr> <tr><td><b>Gender</td><td> </td> <td>$row[Gender]</td</tr> <tr><td><b>Race</td><td> </td> <td>$row[Race]</td</tr> <tr><td><b>Suspension</td><td> </td> <td>$row[suspensions]</td</tr> <tr><td><b>Period</td><td> </td> <td>$row[Period]</td></tr> <tr><td><b>Date Recieved</td><td> </td> <td>$row[Date_Recieved]</td</tr> <tr><td><b>Unit</td><td> </td> <td>$row[unit]</td</tr> <tr><td><b>Region</td><td> </td> <td>$row[Region]</td</tr> <tr><td><b>Date Of DC</td><td> </td> <td>$row[Date_Of_DC]</td</tr> <tr><td><b>Status</td><td> </td> <td>$row[status]</td</tr> <tr><td><b>Category</td><td> </td> <td>$row[Category]</td></tr> <tr><td><b>Outcome</td><td> </td> <td>$row[Outcome]</td></tr></table></td><td> </td><td valign='top'><table width='300'> <tr><td valign='top'><b>Status Report</td><td> </td> <td width='250'>$row[status_Report]</td></tr> <tr><td></td></tr> </table></table> </form>"; }; ?> Quote Link to comment https://forums.phpfreaks.com/topic/73937-pagination-script-needed/#findComment-373083 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.