i know this has been discussed in alot of places on here i did a search and i read about 10 threads on this, and none of these ideas helped me out, i tried cgraz (sp) script with no luck
then i did this one by Rob, written in an article on here.
<?
//include the db connection's
include("config.php");
$limit=4; // rows to return
$numresults=mysql_query("select * from catalog ");
$numrows=mysql_num_rows($numresults);
// next determine if offset has been passed to script, if not use 0
if (empty($offset)) {
$offset=1;
}
// get results
$result=mysql_query("SELECT * FROM catalog ORDER BY id DESC LIMIT $offset,$limit ");
// now you can display the results returned
while ($row=mysql_fetch_array($result)) {
// include code to display results as you see fit
echo "<tr><td>".$row["1"]." </td><td>".$row["6"]." </td><td>".$row["2"]." </td><td>";
echo "<a href=\"image.php?id=".$row["0"]."\">".$row["7"]."</a>";
}
echo "</td></tr></table>";
// next we need to do the links to other results
echo "<center>";
if ($offset==1) { // bypass PREV link if offset is 0
$prevoffset=$offset-20;
print "<center><a href=\"$PHP_SELF?offset=$prevoffset\">PREV</a> \n";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
for ($i=1;$i<=$pages;$i++) { // loop thru
$newoffset=$limit*($i-1);
print "<a href=\"$PHP_SELF?offset=$newoffset\">$i</a> \n";
}
// check to see if last page
if (!(($offset/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$newoffset=$offset+$limit;
print "<a href=\"$PHP_SELF?offset=$newoffset\">NEXT </a><p></center>\n";
}
echo "</center>";
?>
now it is not giving me any errors and it looks fine, but there is a bug, more like 2 or 3.
my issue is that it doesn't not grab the last id inserted into the database and that I dont' understand, it should show up frist as it's ORDER BY id DESC.
next we have that if you click on next or page 2 the last 3 from page 1 shows up with 1 new one and page 3 does the same, which is a total of 5 results, when really there's 9 for now.
any help is greatly appreciated, i'm lost, i printed this script so i could read it over tonight and maybe find the bug myself.
thanks alot!