Forum Moderators: coopster
<?
$user="*****";
$password="*****";
$database="*****";
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
?>
<?
$link = mysql_connect("*****", "*****", "*****");
mysql_select_db("*****", $link);
?>
<?
$pagemove = 1;
$increment = 8;
$page = (int) $_GET['page'];
$page = (isset($_GET['page'])) ? $page : 1;
$result = mysql_query("SELECT * FROM countries WHERE country_category='europe'", $link);
$num_rows = mysql_num_rows($result);
$mull = ($num_rows - 8) * $page;
$query="SELECT * FROM country WHERE country_category='europe' LIMIT ";
$query .= $page * $increment - $increment . ", " . $increment;
$result = mysql_query($query);
mysql_close();
echo "<b><center><br />European Countries</center></b><br><br>";
while ($row = mysql_fetch_array($result))
{
echo '<a href="' . $row['country_link'] . '"target="_blank">' . $row['country_name'] . '<br /><br /></a><br /> ';
}
if ($page > 1) {
$prev = $page - $pagemove;
$url = $_SERVER['PHP_SELF']."?page=$prev";
printf("<a href='%s'><br /><b>Previous Page</b></a>", $url);
}
if ($num_rows > ($increment + $page)) {
$next = $page + $pagemove;
$url = $_SERVER['PHP_SELF']."?page=$next";
printf("<a href='%s'><br /><b>Next Page</b></a>", $url);
}
?>
Thanks..
change $increment + $page to $increment * $page
If you have 40 results you should have 5 pages
in this case $num_rows = 40, $increment = 8 and $page will = 1, so you show the next button if $num_rows is greater then 9, your next page will do 8 + 2 (page 2) and thus be checking if 40 is greater then 10. The way it current is shown you should lose the next button at about page 32.