Originally posted by cgraz
If you just want prev | next, then drop the for loop out that creates the 1 2 3 4 5 page numbers.
for ($i=1; $i<=$pagenums; $i++) {
if ($i!=$page) {
echo " <a href='yourpage.php?page=$i' class=main>$i</a>";
}
else {
echo " <b class='red'>$i</b>";
}
}
If you want 25 results per page, change the $pagelimit variable to 25. The rest should all be the same.
I'm not sure what you mean by you don't want a page limit. If you want next and previous, then you'll need a pagelimit. The variable just helps you display x amount of results per page.
I also don't see anywhere in your code where you have the next and previous buttons. You also need to make sure you run your select query twice. The first time to do run some basic calculations, the second time using LIMIT to display the right amount of results per page. Re-read the first page w/the code; it's all commented and easy to follow.
Cgraz [/B]
When i sayd a page limit i meant i dont want a maximum pages to be displayed just want a maximum of results per page.
i will tell you exactly what i wanted to do!
Lets say that I have a list of books for a store, the table will contains id, name, genere, review, picture, details
now, the books will be shown by id desc. so is (order by id desc)
The code i have is this:
$offset=2;
if (!isset($min)) $min=0;
if (!isset($max)) $max=$min+$offset;
$result = sql_query("select * from ".$prefix."_lista_de_juegos order by jid DESC limit $min,$offset",$dbi);
if(!$result) die(_ERROR."<br>");
$nrows = sql_num_rows($result, $dbi);
$x=0;
while (list($jid, $jnombre, $jgenero, $jreview, $jdcreenshot, $jdemo) = sql_fetch_row($result, $dbi))
echo "<center><table width=\"90%\" border=\"0\" cellspacing=\"4\" cellpadding=\"0\" align=\"center\">
<tr>
<td>".$jnombre."</td>
<td>".$jgenero."</td>
<td>".$jreview."</td>
<td>".$jscreenshot."</td>
<td>".$jdemo."</td>
</tr>
</table></center>";
echo "<center>";
$prev=$min-$offset;
if ($prev>=0) {
print "<a href=\"dont know\">";
print "<img src=\"images/buttons/previous.gif\" border=\"0\" title=\""._PREV." "._RESULTS."\"></a> ";
}
$next=$min+$offset;
if ($x>=2) {
print "<a href=\"dont know\">";
print "<img src=\"images/buttons/next.gif\" border=\"0\" title=\""._NEXT." "._RESULTS."\"></a>";
}
echo "</center>";
To be totally honest i'm using another code i found on phpnuke, i'm still learning php and i cant get this to work. maybe implementing your code will do the trick, just i dont know how to implement it.
any idea of how?