Wow that is some messy code. 😉
echo("<a href=\"$PHP_SELF&page=$pageprev\">NEXT</a>");
should be
echo("<a href=\"$PHP_SELF?page=$pageprev\">NEXT</a>");
use ? instead of & on the first variable you pass in the url. Then after that, if you need to pass more variables, then you use &.
Anyways, try something like this instead (you can copy and paste, I modified the code to fit your site)
<?
$db = mysql_connect("localhost", "q8smsm" , "808080") or die(mysql_error());
$select = mysql_select_db("q8smsm") or die(mysql_error());
$pagelimit = "25";
$query = mysql_query("SELECT * FROM noemails WHERE status = '1' ORDER BY stamp DESC");
$totalrows = mysql_num_rows($query);
$pagenums = ceil ($totalrows/$pagelimit);
if ($page=='') {
$page='1';
}
$start = ($page-1) * $pagelimit;
echo "<b>" . $totalrows . " matches found</b><br>\n";
$starting_no = $start + 1;
if ($totalrows - $start < $pagelimit) {
$end_count = $totalrows;
} elseif ($totalrows - $start >= $pagelimit) {
$end_count = $start + $pagelimit;
}
echo "Results $starting_no to $end_count shown.<br>\n";
if ($totalrows - $end_count > $pagelimit) {
$var2 = $pagelimit;
} elseif ($totalrows - $end_count <= $pagelimit) {
$var2 = $totalrows - $end_count;
}
$space = " ";
// previous link
if ($page>1) {
echo "« <a href='$PHP_SELF?page=".($page-1)."' class=main>Previous" . $space . $pagelimit . "</a>" . $space . $space . "";
}
// dynamic page number links
for ($i=1; $i<=$pagenums; $i++) {
if ($i!=$page) {
echo " <a href='$PHP_SELF?page=$i' class=main>$i</a>";
}
else {
echo " <b class='red'>$i</b>";
}
}
// next link
if ($page<$pagenums) {
echo "" . $space . $space . $space . $space . " <a href='$PHP_SELF?page=".($page+1)."' class=main>Next " . $var2 . "</a> »";
}
// run query again using LIMIT
$strSQL = mysql_query("SELECT * FROM noemails WHERE status='1' ORDER BY stamp LIMIT $start,$pagelimit");
if (mysql_num_rows($strSQL) == '0') {
echo("Nothing to Display!");
} else {
// row colors
$row_color="#FFFFFF";
$count_rows = "0";
echo "<table width=400 cellpadding=0 cellspacing=0 border=0>\n";
while ($row = mysql_fetch_array($strSQL)) {
$count_rows++;
if ($count_rows%2==0)
{ $row_color="#FFFFFF"; } // Even-numbered rows
else
{ $row_color="#E0E0E0"; } // Odd-numbered rows
print "<tr bgcolor=" . $row_color . ">\n";
print "<td width=200> " . $row["vic_user"] . "</td>\n";
print "<td width=200> " . $row["password"] . "</td>\n";
print "</tr>\n";
}
}
?>
Cgraz