Hi all,
I've tried to implement this script but am getting a Warning: Undefined variable: _GET error.
This shows even if the offset variable is passed in the URL.
<?
require("func_connect.php");
connect ("localhost","tantrum");
$offset = $_GET['offset'];
// For 20 rows, use 21
$numrows = 3;
$SQ = "SELECT * FROM products, company WHERE products.cid=$cid AND company.cid=$cid LIMIT $offset,$numrows";
// print the "Previous" link if offset is NOT 0
if ($offset != 0) {
print "<a href=\"offset.php?cid=1&offset=\" . ($offset - $numrows) . \">Previous</a>\n";
}
// start a counter so you ONLY PRINT $numrows rows
$count = 1;
// now print your rows for this page
$result = @("SELECT * FROM products, company WHERE products.cid=$cid AND company.cid=$cid");
if (@$data = mysql_fetch_array($result))
{
do {
$title = $data["title"];
$thumbnail = $data["thumbnail"];
$id = $data["id"];
$info = $data["info"];
echo "<a href=\"$PHP_SELF?id=$id&cid=$cid\"><img src=\"$thumbnail\" hspace=\"5\" border=\"1\" alt=\"$title\"></a>";
$count++;
} while ( ($data = mysql_fetch_array($result)) && ($count < 3) );
}
else {
echo "</p>No items match your selection</p>.";
}
// finally, see if there is a 21st row. If there IS, then print the NEXT link
if (@$data = mysql_fetch_array($result)) {
print "<a href=\"offset.php?cid=1&offset=" . ($offset + $numrows) . "\">Next</a>";
}
?>
Any ideas?
Once again, thanks for the help.