TaP
04-12-2002, 08:32 PM
how do i make a top 10 counter for this script below? it is the hack counter and i was just wondering how you would make it read the top 10 hack posters
*********************************
In showthread.php, replace this:
*********************************
$getpostids=$DB_site->query("
SELECT post.postid FROM post
WHERE post.threadid='$threadid' AND post.visible=1
ORDER BY dateline $postorder LIMIT ".($limitlower-1).",$perpage
");
if ($limitupper>$totalposts) {
$limitupper=$totalposts;
if ($limitlower>$totalposts) {
$limitlower=$totalposts-$perpage;
}
}
if ($limitlower<=0) {
$limitlower=1;
}
$postids="post.postid IN (0";
while ($post=$DB_site->fetch_array($getpostids)) {
$postids.=",".$post['postid'];
}
$postids.=")";
*********************************
with this:
*********************************
$getpostids=$DB_site->query("
SELECT post.postid,post.userid AS postuserid FROM post
WHERE post.threadid='$threadid' AND post.visible=1
ORDER BY dateline $postorder LIMIT ".($limitlower-1).",$perpage
");
if ($limitupper>$totalposts) {
$limitupper=$totalposts;
if ($limitlower>$totalposts) {
$limitlower=$totalposts-$perpage;
}
}
if ($limitlower<=0) {
$limitlower=1;
}
$postids="post.postid IN (0";
$hackuserids="(0";
while ($post=$DB_site->fetch_array($getpostids)) {
$postids.=",".$post['postid'];
$hackuserids.=",".$post['postuserid'];
}
$postids.=")";
$hackuserids.=")";
$hacks=array();
$hackcounts=$DB_site->query("SELECT postuserid,COUNT(*) AS totalhacks FROM thread WHERE forumid IN (x) AND postuserid IN $hackuserids GROUP BY postuserid");
while ($hackcount=$DB_site->fetch_array($hackcounts)) {
if (!isset($hackcount[totalhacks]))
$hackcount[totalhacks]=0;
$hacks["$hackcount[postuserid]"]=$hackcount[totalhacks];
}
$hacks[0]=0;
*********************************
Still in showthread.php, add this:
*********************************
if ($hacks["$post[userid]"]!='') {
$post[hacks]="<a href=\"member.php?s=$session[sessionhash]&action=getinfo&userid=$post[userid]\">".$hacks["$post[userid]"]."</a>";
} else {
$post[hacks]=0;
}
*********************************
right after this:
*********************************
while ($post=$DB_site->fetch_array($posts) and $counter++<$perpage) {
*********************************
Then use $post[hacks] in the postbit template to show the number of threads the user started in that forum. It will link to the user profile if he has more than 0 threads.
*********************************
In showthread.php, replace this:
*********************************
$getpostids=$DB_site->query("
SELECT post.postid FROM post
WHERE post.threadid='$threadid' AND post.visible=1
ORDER BY dateline $postorder LIMIT ".($limitlower-1).",$perpage
");
if ($limitupper>$totalposts) {
$limitupper=$totalposts;
if ($limitlower>$totalposts) {
$limitlower=$totalposts-$perpage;
}
}
if ($limitlower<=0) {
$limitlower=1;
}
$postids="post.postid IN (0";
while ($post=$DB_site->fetch_array($getpostids)) {
$postids.=",".$post['postid'];
}
$postids.=")";
*********************************
with this:
*********************************
$getpostids=$DB_site->query("
SELECT post.postid,post.userid AS postuserid FROM post
WHERE post.threadid='$threadid' AND post.visible=1
ORDER BY dateline $postorder LIMIT ".($limitlower-1).",$perpage
");
if ($limitupper>$totalposts) {
$limitupper=$totalposts;
if ($limitlower>$totalposts) {
$limitlower=$totalposts-$perpage;
}
}
if ($limitlower<=0) {
$limitlower=1;
}
$postids="post.postid IN (0";
$hackuserids="(0";
while ($post=$DB_site->fetch_array($getpostids)) {
$postids.=",".$post['postid'];
$hackuserids.=",".$post['postuserid'];
}
$postids.=")";
$hackuserids.=")";
$hacks=array();
$hackcounts=$DB_site->query("SELECT postuserid,COUNT(*) AS totalhacks FROM thread WHERE forumid IN (x) AND postuserid IN $hackuserids GROUP BY postuserid");
while ($hackcount=$DB_site->fetch_array($hackcounts)) {
if (!isset($hackcount[totalhacks]))
$hackcount[totalhacks]=0;
$hacks["$hackcount[postuserid]"]=$hackcount[totalhacks];
}
$hacks[0]=0;
*********************************
Still in showthread.php, add this:
*********************************
if ($hacks["$post[userid]"]!='') {
$post[hacks]="<a href=\"member.php?s=$session[sessionhash]&action=getinfo&userid=$post[userid]\">".$hacks["$post[userid]"]."</a>";
} else {
$post[hacks]=0;
}
*********************************
right after this:
*********************************
while ($post=$DB_site->fetch_array($posts) and $counter++<$perpage) {
*********************************
Then use $post[hacks] in the postbit template to show the number of threads the user started in that forum. It will link to the user profile if he has more than 0 threads.