Forum Moderators: coopster
=======================================
<?php
include("config.php");?>
<?
// get the pager input values
$page = $_GET['page'];
$limit = 12;
$result = mysql_query("select count(*) from $table_link");
$total = mysql_result($result, 0, 0);?>
<?
// use pager values to fetch data
$query = "SELECT * FROM $table_link ORDER BY name DESC()LIMIT $offset, $limit";
$result = mysql_query($query);
$i=0;
$i2=$i+1;
while ($i < $num) {
$image=mysql_result($result,$i,"image");
$name=mysql_result($result,$i,"name");
?>
<img border="0" src="<?=$base_url?><?=image?>" alt="<?=$name?>"></a>
<?
++$i;
}?>
<? // output paging system (could also do it before we output the page content)
if ($page == 1) // this is the first page - there is no previous page
echo "Previous";
else // not the first page, link to the previous page
echo "<a href=\"page.php?page=" . ($page - 1) . "\">Previous</a>";
for ($i = 1; $i <= $pager->numPages; $i++) {
echo " ¦ ";
if ($i == $pager->page)
echo "Page $i";
else
echo "<a href=\"page.php?page=$i\">Page $i</a>";
}
if ($page == $pager->numPages) // this is the last page - there is no next page
echo "Next";
else // not the last page, link to the next page
echo "<a href=\"page.php?page=" . ($page + 1) . "\">Next</a>";
?>
It would be helpful to know what is going wrong with your page. Are you getting an error message? Is there no output? Is there bad output?
For instance, you use $offset before setting it, but you might have just not included that code snippet. Any more details on what exactly is going wrong, and I'm sure someone will be able to help.
Chad