so i cooked up a new look for pagination > screen attached
so i need someone to get top pagination to work
since query is between top and bottom pagination code
top one is not working
code is all right i think i haven't messed anything up
only "Jump to" is still just a placeholder haven't wrote jquery for that jet
so here is my torrents.php
Code:
<?php
if (defined('IN_PMBT'))die ("You can't include this file");
define("IN_PMBT",true);
include("header.php");
require('actb.php');
echo "<div class=\"topic_controls\">
<ul class=\"pagination bottom left\">
<li class=\"total pagejump clickable\">Jump to
<img src=\"$siteurl/themes/$theme/pics/imperial/dropdown.png\" alt=\"+\" />
</li>".$prev."".(($pages > 1) ? $pager : "")."".$next."</ul>
<ul class=\"topic_buttons\">
<li><a href=\"upload.php?op=link\" title=\"\">
<img src=\"$siteurl/themes/$theme/pics/imperial/topic_watch.png\" alt=\"\" />Upload ed2k link</a>
</li>
<li><a href=\"upload.php?op=torrent\" title=\"\">
<img src=\"$siteurl/themes/$theme/pics/imperial/page_white_add.png\" alt=\"\" />Upload torrent</a>
</li>
</ul>
</div>";
echo "
<div id=\"forum_filter\" class=\"filter_bar rounded\">
<span id=\"show_filters\" class=\"clickable\">Click here to toggle CATEGORIES</span>
</div>
<div class=\"categories_form\"><div class=\"border\"><div id=\"tbg\">
<table class=\"bottom\">
<tr>";
$i = 0;
foreach (catlist() as $c) {
$i++;
echo "<td class=\"bottom\" style=\"padding-bottom: 2px; padding-left: 7px;\" align=\"left\"><input value=\"1\" type=\"checkbox\"><a href=\"torrents.php?cat=".$c["id"]."\">".$c["name"]."</a></td>";
if ($i == 6) {
echo "</tr><tr>";
$i = 0;
}
}
echo "</tr></table>";
echo"</div></div></div><div id=\"myborder\"></div>";
#OBT: Add joe's table-head sorting function:
$sort = (isset($_GET["sort"])) ? $_GET["sort"] : '';
$type = (isset($_GET["type"])) ? $_GET["type"] : '';
$orderby = " ORDER BY ".$db_prefix."_torrents.evidence DESC, ";//
if ($sort == 1) $orderby = " ORDER BY ".$db_prefix."_torrents.name $type, ";//
if ($sort == 2){
$orderby = " ORDER BY ".$db_prefix."_torrents.numfiles $type, ";//
}
if ($sort == 3){
$orderby = " ORDER BY ".$db_prefix."_torrents.comments $type, ";//
}
if ($sort == 4){
$orderby = " ORDER BY ".$db_prefix."_torrents.category $type, ";//
}
if ($sort == 5){
$orderby = " ORDER BY ".$db_prefix."_torrents.size $type, ";
}
if ($sort == 6){
$orderby = " ORDER BY ".$db_prefix."_torrents.times_completed $type, ";
}
if ($sort == 7){
$orderby = " ORDER BY ".$db_prefix."_torrents.seeders $type, ";//
}
if ($sort == 8){
$orderby = " ORDER BY ".$db_prefix."_torrents.leechers $type, ";//
}
if ($onlysearch) {
OpenTable(_btnosearchttl);
echo _btnosearch;
CloseTable();
} else {
if (!isset($page) OR !is_numeric($page) OR $page < 1) $page = 1;
if (!isset($cat)) $cat = "";
if (intval($cat) > 0) $catwhere = " AND ".$db_prefix."_torrents.category = ".intval($cat);
else $catwhere = "";
$passwhere = " AND ".$db_prefix."_torrents.password IS NULL ";
$viswhere = "visible = 'yes' AND banned = 'no'";
if ($user->moderator) $viswhere = "1";
if ($user->premium) $passwhere = "";
$from = ($page - 1) * $torrent_per_page;
$totsql = "SELECT COUNT(*) as tot FROM ".$db_prefix."_torrents WHERE ".$viswhere.$catwhere.$passwhere.";";
$sql = "SELECT ".$db_prefix."_torrents.*, IF(".$db_prefix."_torrents.numratings < '".$minvotes."', NULL, ROUND(".$db_prefix."_torrents.ratingsum / ".$db_prefix."_torrents.numratings, 1)) AS rating, ".$db_prefix."_categories.name AS cat_name, ".$db_prefix."_categories.image AS cat_pic, U.username, IF(U.name IS NULL, U.username, U.name) as user_name, U.level as user_level FROM ".$db_prefix."_torrents LEFT JOIN ".$db_prefix."_categories ON category = ".$db_prefix."_categories.id LEFT JOIN ".$db_prefix."_users U ON ".$db_prefix."_torrents.owner = U.id WHERE ".$viswhere.$catwhere.$passwhere.$orderby.$db_prefix."_torrents.added DESC LIMIT ".$from.",".$torrent_per_page.";";
$res = $db->sql_query($sql) or btsqlerror($sql);
$totres = $db->sql_query($totsql);
if (isset($sort))$sort1= "&sort=".$sort."&type=".$type;
else
$sort1="";
if (isset($sort))$sort2= "?sort=".$sort."&type=".$type;
else
$sort2="";
list ($tot) = $db->sql_fetchrow($totres);
$db->sql_freeresult($totres);
if ($db->sql_numrows($res) > 0) {
$pages = ceil($tot / $torrent_per_page);
if($page < $pages & $cat) {
$next = "<a href=\"torrents.php?page=".($page+1)."&cat=".$cat."\"><li class=\"next\">></li></a>";
} elseif($page < $pages ) {
$next = "<a href=\"torrents.php?page=".($page+1).$sort1."\"><li class=\"active\">></li></a>";
}else{
$next = "<li class=\"next\">></li>";
}
if($page > 1 & $cat) {
$prev = "<a href=\"torrents.php?page=".($page-1)."&cat=".$cat."\"><li class=\"prev\"><</li></a>"; } elseif($page > 1) {
$prev = "<a href=\"torrents.php?page=".($page-1).$sort1."\"><li class=\"active\"><</li></a>";
}else{
$prev = "<li class=\"prev\"><</li>";
}
if($cat){
$pager = "<a href=\"torrents.php?cat=".$cat."\">".(($page == 1) ? "<li class=\"active\">1</li>" : "<li class=\"inside2\">1</li>")."</a>";
if (($page - 15) > 1) $pager .= "...";
for ($i = max(2,$page - 15); $i < min($pages, $page + 15); $i++) {
$pager .= "<a href=\"torrents.php?page=".$i."&cat=".$cat."\">".(($i == $page) ? "<li class=\"active\">".$i."</li>" : "<li class=\"inside2\">".$i."</li>")."</a>";
}
if (($page + 15) < $pages) $pager .= "...";
$pager .= "<a href=\"torrents.php?page=".$pages."&cat=".$cat."\">".(($page == $pages) ? "<li class=\"active\">".$pages."</li>" : "<li class=\"inside2\">".$pages."</li>")."</a>";
torrenttable($res);
}else {
$pager = "<a href=\"torrents.php".$sort2."\">".(($page == 1) ? "<li class=\"active\">1</li>" : "<li class=\"inside2\">1</li>")."</a>";
if (($page - 15) > 1) $pager .= "...";
for ($i = max(2,$page - 15); $i < min($pages, $page + 15); $i++) {
$pager .= "<a href=\"torrents.php?page=".$i.$sort1."\">".(($i == $page) ? "<li class=\"active\">".$i."</li>" : "<li class=\"inside2\">".$i."</li>")."</a>";
}
if (($page + 15) < $pages) $pager .= "...";
$pager .= "<a href=\"torrents.php?page=".$pages.$sort1."\">".(($page == $pages) ? "<li class=\"active\">".$pages."</li>" : "<li class=\"inside2\">".$pages."</li>")."</a>";
torrenttable($res);
}
echo "<div class=\"topic_controls\">
<ul class=\"pagination bottom left\">
<li class=\"total pagejump clickable\">Jump to
<img src=\"$siteurl/themes/$theme/pics/imperial/dropdown.png\" alt=\"+\" />
</li>".$prev."".(($pages > 1) ? $pager : "")."".$next."</ul></div>";
}
}
include("footer.php");
?>