Well, I have not tried to change the query, although it was with that intention that I openned the script for modification. I ended up adding a much nicer navigation bar.
To use it, find your favourite First, Previous, Next and Last graphics and replace nav_first_on.gif, nav_first_off.giff, nav_prev_on.gif, &c, in the following code. I added one more variable,
$smilieslinklast, to determine whether or not to enable the navigation for the last page button.
Code:
if ($action=="showsmilies") {
// 2000-07-26 PEH - hacked to add LIMIT clause to break up ShowSmilies page
if (!isset($startsmilies)) {
$startsmilies=0;
}
// added LIMIT statement, hard coded "30" as the per page value
// (should move this to a variable in the control panel, though)
$smilies=$DB_site->query("SELECT smilietext,title,smiliepath FROM smilie ORDER BY title LIMIT $startsmilies,30");
while ($smilie=$DB_site->fetch_array($smilies)) {
$smilietext=$smilie[smilietext];
$smiliepath=$smilie[smiliepath];
$title=$smilie[title];
eval("\$smiliebits .= \"".gettemplate("smiliebit")."\";");
}
// $smiliescount is the total number of smilies in the database
$smiliescountresult=$DB_site->query("SELECT COUNT(*) AS Total FROM smilie");
$smiliescountrow=$DB_site->fetch_array($smiliescountresult);
$smiliescount=$smiliescountrow["Total"];
// display the current range for information only
$smilieslink .= "Smilies " . ($startsmilies+1) . " to " . min(($startsmilies+30),($smiliescount+0)) . " of " . $smiliescount . "<br>";
// display a link to the previous page, if needed
if ($startsmilies>29) {
$linkstartsmilies=$startsmilies-30;
$smilieslink .= "<a HREF=\"index.php?action=showsmilies&startsmilies=0\"><img src=\"images/nav_first_on.gif\" border=0 alt=\"First Page\"></a>";
$smilieslink .= "<a HREF=\"index.php?action=showsmilies&startsmilies=$linkstartsmilies\"><img src=\"images/nav_prev_on.gif\" border=0 alt=\"Previous Page\"></a>";
} else {
$smilieslink .= "<img src=\"images/nav_first_off.gif\" border=0 alt=\"At first page, already\">";
$smilieslink .= "<img src=\"images/nav_prev_off.gif\" border=0 alt=\"At first page, already\">";
}
// display a link to the next page, if needed
if ($startsmilies<$smiliescount-30) {
$linkstartsmilies=$startsmilies+30;
$smilieslink .= "<a HREF=\"index.php?action=showsmilies&startsmilies=$linkstartsmilies\"><img src=\"images/nav_next_on.gif\" border=0 alt=\"Next Page\"></a>";
} else {
$smilieslink .= "<img src=\"images/nav_next_off.gif\" border=0 alt=\"At last page, already\">";
}
// add the "Last Page" link
$smilieslinklast=$smiliescount-$smiliescount%30;
if ($smilieslinklast>$startsmilies) {
$smilieslink .= "<a HREF=\"index.php?action=showsmilies&startsmilies=" . $smilieslinklast . "\"><img src=\"images/nav_last_on.gif\" border=0 alt=\"Last Page\"></a>";
} else {
$smilieslink .= "<img src=\"images/nav_last_off.gif\" border=0 alt=\"At last page, already\">";
}
eval("echo dovars(\"".gettemplate("smilies")."\");"); // added line to "smilies" to show link to previous and/or next page
}