pgowder
04-04-2002, 10:00 PM
This is my first "hack". (Not really a hack, just a combination of two.)
I wanted to be able to combine these two hacks, so here is what I did.
This will give you a table with the totals.
You need to make sure that al the fields in your storepoint table are not null and default 0.
Hope you enjoy.
<html>
<head>
</head>
<body>
<table CELLSPACING=0 BORDER=1 WIDTH=70% align="center">
<tr BGCOLOR=#3300CC>
<td align="center"><font color="white" size="+1"><b>Username</b></font></td><td align="center"><font color="white" size="+1"><b>Karma Points</b></font></td><td align="center"><font color="white" size="+1"><b>Views</b></font></td><td align="center"><font color="white" size="+1"><b>Total</b></font></td>
</tr>
<?
$hostname = "";
$username = "";
$password = "";
$dbName = "";
MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to database");
@mysql_select_db("$dbName") or die("Unable to select database");
$query = "select uid, newthread+reply+view+admin_mod+morereply+totalpena lty as total from storepoint order by total desc";
$my_q = mysql_query($query) or die(mysql_error());
$row_count = mysql_num_rows($my_q);
for ($i=0; $i<$row_count; $i++) {
list($uid, $total) = mysql_fetch_row($my_q);
$my_q2 = mysql_query("select username, views from user where userid='$uid'") or die(mysql_error());
list($username, $views) = mysql_fetch_row($my_q2);
$karmatotal = $total + $views;
print "<tr><td BGCOLOR=#ffffcc>$username</td><td BGCOLOR=#ffffcc align=center>$total</td><td BGCOLOR=#ffffcc align=center>$views</td><td BGCOLOR=#ffffcc align=center>$karmatotal</td></tr>";
mysql_free_result($my_q2);
}
mysql_free_result($my_q);
?>
</table>
</body>
</html>
I wanted to be able to combine these two hacks, so here is what I did.
This will give you a table with the totals.
You need to make sure that al the fields in your storepoint table are not null and default 0.
Hope you enjoy.
<html>
<head>
</head>
<body>
<table CELLSPACING=0 BORDER=1 WIDTH=70% align="center">
<tr BGCOLOR=#3300CC>
<td align="center"><font color="white" size="+1"><b>Username</b></font></td><td align="center"><font color="white" size="+1"><b>Karma Points</b></font></td><td align="center"><font color="white" size="+1"><b>Views</b></font></td><td align="center"><font color="white" size="+1"><b>Total</b></font></td>
</tr>
<?
$hostname = "";
$username = "";
$password = "";
$dbName = "";
MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to database");
@mysql_select_db("$dbName") or die("Unable to select database");
$query = "select uid, newthread+reply+view+admin_mod+morereply+totalpena lty as total from storepoint order by total desc";
$my_q = mysql_query($query) or die(mysql_error());
$row_count = mysql_num_rows($my_q);
for ($i=0; $i<$row_count; $i++) {
list($uid, $total) = mysql_fetch_row($my_q);
$my_q2 = mysql_query("select username, views from user where userid='$uid'") or die(mysql_error());
list($username, $views) = mysql_fetch_row($my_q2);
$karmatotal = $total + $views;
print "<tr><td BGCOLOR=#ffffcc>$username</td><td BGCOLOR=#ffffcc align=center>$total</td><td BGCOLOR=#ffffcc align=center>$views</td><td BGCOLOR=#ffffcc align=center>$karmatotal</td></tr>";
mysql_free_result($my_q2);
}
mysql_free_result($my_q);
?>
</table>
</body>
</html>