Here is code that i use:
<?
require "./common.php";
if(file_exists("$include_path/header$ForumConfigSuffix.php")){
include "$include_path/header$ForumConfigSuffix.php";
} else {
include "$include_path/header.php";
}
$result = "Select * from ".$pho_main."";
$q->query($DB, $result);
$counter = 0;
$q->query($DB, $sql);
?>
<center>
<table border=0 cellspacing=1 cellpadding=0 width="50%"><tr BGCOLOR="#000000"><td>
<table border=0 cellspacing=1 cellpadding=2 width="100%">
<tr <?PHP echo bgcolor($ForumNavColor); ?>><td colspan="4">
<center>
Top
<a href="top.php?f=<? echo $num; ?>&top=10">10</a> |
<a href="top.php?f=<? echo $num; ?>&top=15">15</a> |
<a href="top.php?f=<? echo $num; ?>&top=30">30</a> |
<a href="top.php?f=<? echo $num; ?>&top=50">50</a> |
<a href="top.php?f=<? echo $num; ?>&top=100">100</a>
</center><tr <?PHP echo bgcolor($ForumTableHeaderColor); ?>><td width="2">#</td><td>Author</td><td>Posts</td><td>% Of Total</td></tr>
<?
while ($row = $q->getrow()){
$sSQL="select count() as posts from $row[table_name] where approved='Y'";
$tq = new query($DB, $sSQL);
if($tq->numrows()){
$trec=$tq->getrow();
$num_posts=$trec["posts"];
}
else{
$num_posts='0';
}
$sSQL = "SELECT author, count() as total FROM $row[table_name] GROUP BY 1 ORDER BY 2 DESC LIMIT 10";
$numb="0";
$tf = new query($DB, $sSQL);
while ($rowcount = $tf->getrow()){
$counter += $rowcount[1];
$total = $rowcount["total"];
$percentage = $total/$num_posts"100";
$rounded=round(100$percentage)/"100";
$author = $rowcount["author"];
$numb=++$numb;
echo "<tr bgcolor=\"#FFFFFF\"><td>$numb.</td><td> $author</td><td>$total</td><td>$rounded%</td></tr>";
}
}
echo "</table>\n";
echo "</td></tr> \n";
echo "</table>\n";
echo "</center>\n";
if(file_exists("$include_path/footer$ForumConfigSuffix.php")){
include "$include_path/footer$ForumConfigSuffix.php";
} else {
include "$include_path/footer.php";
}
?>
Well, it's a phorum, but it's not much different,
Function
$variable->getrow()
means
mysql_fetch_array
and query(
is
mysql_db_query
and $pho_main is where all the table names are stored.
This code that:
http://www.pch.f2s.com/test.php
You can see, how # start again every time when there is new forum, but i need to make top 10 of all forums. Any ideas how to do it?
Any help appriciated.
Vulpes