OK, I have a display page which I want to use to show all entries in my database. The proble is, there are several hundred entried so far and getting bigger every day. I have them to display 30 at a time:
then later, at the bottom of the page, I have:PHP Code:$dbh=mysql_connect ("localhost", "", "") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("");
if(!isset($start)) $start = 0;
$query="SELECT * FROM CD ORDER BY groupname, album ASC LIMIT " .$start. ", 30";
$result=mysql_query($query);
Question is...how do I find the total, then list page 1,2,3,4,5,etc. so one can jump ahead quickly rather than incrementally by 30? Does this make sense?PHP Code:$query = "SELECT count(*) as count FROM CD";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start > 0)
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 30) .
"\"><- Previous</a>\n";
if($numrows > ($start + 30))
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 30) .
"\">Next -></a><BR>\n";


LinkBack URL
About LinkBacks






Reply With Quote