Below is my script that list out all the entries of my mysql table (hit counter). My mySQL table has over 70 000 entries and I want to list them out. The problem with the script below is that it lists out all the over 70 000 entries. This takes ages to do. Can anybody help me with this script so I can only view eg 50 enrties a time. I guess I have to use pages and limit, but dont know how to attack this.
<?php
include("connect.php");
$order=$_GET['order'];
if(!$order) {
$order="id";
}
$sql = mysql_query("SELECT * FROM $table order by $order desc limit 0,20");
$head = array('Number','IP','Date_Now','Date_First','Browser');
echo "<table border=1><tr>";
foreach($head as $part) {
if($order==$part) {
echo "<td bgcolor=lightgreen><a class=cd href=vis_teller.php?order=$part>$part</a></td>";
}
elseif($part=="Number") {
echo "<td bgcolor=lightgrey>$part</td>";
}
else {
echo "<td bgcolor=lightgrey><a class=cd href=vis_teller.php?order=$part>$part</a></td>";
}
}
echo "</tr>";
while ($row = mysql_fetch_array($sql)) {
$teller++;
echo "<tr>";
echo "<td>$teller</td>";
echo "<td>".$row['ip']."</td>";
echo "<td>".$row['date_now']."</td>";
echo "<td>".$row['date_first']."</td>";
echo "<td>".substr($row['browser'],0,83)."</td>";
echo "</tr>";
}
echo "</table>";
?>