FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Pagination





welshsteve
This has probably been asked before, and I have trawled the net looking for a simple solution to this, but all the tutorials I have found I haven't been able to figure out how to implement.

Here is a PHP script I have for pulling data from a database and displaying it on my page.

Code:

<?php
$division = 'Breaks_Prem';
$con = mysql_connect("SERVER","USER","PASSWORD");
if (!$con)
  {
  die('Could not connect: ' . mysql_error() . '<br /><br />Please contact your web admin team');
  }

mysql_select_db("DBNAME", $con);

$sql = "SELECT * FROM $division ORDER BY Break DESC , Name , Club";
$result = mysql_query($sql);

if (!$result)
echo mysql_error();

echo "
<table class='breaks'>
<tr>
<th class='big'>Name</th>
<th class='big'>Club</th>
<th class='sml'>Break</th>
</tr>";
      
while($row = mysql_fetch_array($result))
  {
   echo "<tr>";
   echo "<td class='left'>&nbsp;" . $row['Name'] . "</td>";
   echo "<td class='left''>&nbsp;" . $row['Club'] . "</td>";
   echo "<td class='middle'>" . $row['Break'] . "</td>";
  echo "</tr>";
  }
echo "</table><p>&nbsp;</p>";

mysql_close($con);
?>


The database has just three fields. NAME, CLUB and BREAK.

I simply want to page the results 20 records at a time, showing something like this below the data.

<<Prev | 1 | 2 | 3 | 4 | Next>>

Is anybody able to help based on the code I have already?
sonam
Here you can find few good posts.

http://www.frihost.com/forums/vt-71187.html

Sonam
Related topics
help with pagination problem
Pagination
Pagination with .html extension
PHP Pagination?
Very basic pagination
Need help - guestbook pagination like [1] [2] [3] etc.
PHP Pagination and Tables
Pagination of data from an UNION query
Pagination for the Frihost Blogs index
Clock-javascript
PHP DB Error: syntax error
+++ 535 FUNNY VIDEOS +++
Managing php pages
Search !!!
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.