arcticbb

It is currently Thu May 31, 2007 12:47 pm

All times are UTC - 5 hours [ DST ]


Forum rules


Please make sure to backup if you have to modify your SQL tables!

Legend:
(Admin) = For Admin Only!
(User) = For Users/Public Only!



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Subcategory Pagination (By guibean) (User)
PostPosted: Fri May 25, 2007 2:19 am 
Offline
x_x

Joined: Tue Apr 24, 2007 2:47 pm
Posts: 39
Example

Replace your subcat.php with the following code:

Code:
<?
/*
Subcategory "pagination" by guibean
Modified for the AK Nova by phrostwave
*/

require_once "config.php";
connect ($dbhost, $dbuser, $dbpass, $database);
$sort = tsort ($_GET['sort']);

$numreg = 25; // Number of items per page
if (!isset($pg)){
    $pg = 0;
}

$inicial = $_GET['pg'] * $numreg;

$result = mysql_query("SELECT * FROM torrents LEFT JOIN categories ON torrents.subcat = categories.subid WHERE subid = '".strip_tags(trim($_GET['id']))."' $sort LIMIT $inicial,$numreg") or die (mysql_error());
$result2 = mysql_query("SELECT * FROM torrents LEFT JOIN categories ON torrents.subcat = categories.subid WHERE subid = '".strip_tags(trim($_GET['id']))."' $sort") or die (mysql_error());
$result_subcatname = mysql_query("SELECT DISTINCT name,catid,subname,subid FROM categories WHERE subid='".strip_tags(trim($_GET['id']))."'") or die (mysql_error());

$count = mysql_num_rows($result2);
$quantreg = $count;

$namerow =  mysql_fetch_row($result_subcatname);
stheader ('Subcategory : '.$namerow[0].' > '.$namerow[2]);


if ($count == 0){
    echo '<h1>No torrents yet! Check back soon =D</h1>';
    footer();
    die;
}

echo '<div class="location"><a href="index.php">Home</a> &raquo; <a href="cat.php?id='.$namerow[1].'">'.$namerow[0].'</a> &raquo; <a href="subcat.php?id='.$namerow[3].'">'.$namerow[2].'</a></div>';
echo '<h1>'.$count.' total torrents in '.$namerow[2].'</h1>';
echo '<table class="tor" width="100%" cellpadding="0" cellspacing="0" border="0"><tr><th><a href="?sort=1">Age</a></th><th><a href="?sort=3">Filename</a></th><th><a href="?sort=4">Size</a></th><th><a href="?sort=5">Seeds</a></th><th><a href="?sort=6">Peers</a></th><th>Health</th></tr>';
while ($row = mysql_fetch_array($result)){
extract($row);
$torrentname = str_replace("+"," ",$torrentname);
$torrentname = str_replace("amp;","",$torrentname);
$torrentname = str_replace("%","",$torrentname);
$torrentname = str_replace("[","",$torrentname);
$torrentname = str_replace("]","",$torrentname);
$torrentname = str_replace(" "," ",$torrentname);
$torrentname = str_replace("avi","",$torrentname);
$torrentname = str_replace("S^M","",$torrentname);
$torrentname = str_replace("com","",$torrentname);
$torrentname = str_replace("mp3","",$torrentname);
$torrentname = str_replace("Lynda","",$torrentname);
$torrentname = str_replace("WWW","",$torrentname);
$torrentname = str_replace("www","",$torrentname);
$torrentname = str_replace("-"," ",$torrentname);

$tz = convert_timestamp($row["added"]); // add this

echo '<tr>';
echo '<td width="10%>'.substr($added,-0).'</td>';
echo '<td width="10%">'.get_elapsed_time($tz).' old!</td>';
echo '<td width="60%"><a href="adm/b/torrents/'.$hash.'.torrent"><img src="images/d.gif" alt="[d]" /></a> '.regicon($registration,$tracker).' '.desc($description).'<a href="details.php?id='.$id.'">'.$torrentname.'</a></td>';
echo '<td width="7%" class="d">'.torsize($size).'</td>';
echo '<td width="5%" class="d">'.getpeer($seeds).'</td>';
echo '<td width="5%" class="d">'.getpeer($peers).'</td>';
echo '<td width="3%" align="center"><img src="images/h'.health($peers, $seeds).'.png"></td>';
echo '</tr>';

}
echo '</table>';

echo "<br>";


if ($quantreg%$numreg==0){
    $quant_pg = intval($quantreg/$numreg);
    $quant_pg++;
}
else{
    $quant_pg = ceil($quantreg/$numreg);
    $quant_pg++;
}

echo'<div class="location">';

if ($quantreg <= $numreg){
echo '';
    footer();
    die;
}

if ($_GET['pg'] > 0){
    echo "<a href=".$_SERVER['PHP_SELF']."?id=".strip_tags(trim($_GET['id']))."&pg=".($_GET['pg']-1)."><b>&laquo; Prev</b></a>";
}
else{
    echo "";
}

for($i_pg=1; $i_pg<$quant_pg;$i_pg++){

    if ($_GET['pg'] == ($i_pg-1)){
        echo "&nbsp;<a class=currentpage href=#><b>$i_pg</b></a>&nbsp;";
    }
    else{
        $i_pg2 = $i_pg-1;
        echo "&nbsp;<a href=".$_SERVER['PHP_SELF']."?id=".strip_tags(trim($_GET['id']))."&pg=$i_pg2><b>$i_pg</b></a>&nbsp;";
    }
}

if (($_GET['pg']+2) < $quant_pg){
    echo "<a href=".$_SERVER['PHP_SELF']."?id=".strip_tags(trim($_GET['id']))."&pg=".($_GET['pg']+1)."><b>Next &raquo;</b></a>";
}
else{
    echo "";
}

echo "</div>";

footer();
?>

_________________
AKNOVA.INFO


Venetian Snares - Hajnal / Szerencsétlen


Report this post
 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
arcticSilver1 template by phrostwave

powered by phpBB © 2002, 2006 phpBB Group
[ Time : 0.098s | 9 Queries | GZIP : On ]