it53lv |
2nd July 2011 12:53 |
help needed on imperialbt torrents.php
1 Attachment(s)
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:
if (defined('IN_PMBT'))die ("You can't include this file");
define("IN_PMBT",true);
include("header.php");
require('actb.php');
echo "";
echo "
Click here to toggle CATEGORIES
";
#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 = ">";
} elseif($page < $pages ) {
$next = ">";
}else{
$next = ">";
}
if($page > 1 & $cat) {
$prev = "<"; } elseif($page > 1) {
$prev = "<";
}else{
$prev = "<";
}
if($cat){
$pager = "".(($page == 1) ? "1" : "1")."";
if (($page - 15) > 1) $pager .= "...";
for ($i = max(2,$page - 15); $i < min($pages, $page + 15); $i++) {
$pager .= "".(($i == $page) ? "".$i."" : "".$i."")."";
}
if (($page + 15) < $pages) $pager .= "...";
$pager .= "".(($page == $pages) ? "".$pages."" : "".$pages."")."";
torrenttable($res);
}else {
$pager = "".(($page == 1) ? "1" : "1")."";
if (($page - 15) > 1) $pager .= "...";
for ($i = max(2,$page - 15); $i < min($pages, $page + 15); $i++) {
$pager .= "".(($i == $page) ? "".$i."" : "".$i."")."";
}
if (($page + 15) < $pages) $pager .= "...";
$pager .= "".(($page == $pages) ? "".$pages."" : "".$pages."")."";
torrenttable($res);
}
echo "
";
}
}
include("footer.php");
?>
|