btw I don't know php, I just hack at it with my SQL and C++ knowledge..
Ok this is the "stats.php" file which lists the most posts from date1 to date2. I seperate out my posts since obviously I don't want to win so I put myself (freddie) down at the bottom.
stats.php (or contest.php)
Code:
<?php require("global.php"); ?>
<html>
<head>
<!-- put any include Styles in here
This is mine:
<?php require '/usr/local/zeus/web_roots/main/www.hedgehogwheels.com/style.html';
?>
-->
<title>Hedgehog Wheels Post Contest</title>
</head>
<body>
<?php
<!-- Date to Start counting Posts -->
<!-- Year-Month-Day -->
$date1 = "UNIX_TIMESTAMP(\"2000-07-08\")";
<!-- Date to Stop Counting Posts -->
$date2 = "UNIX_TIMESTAMP(\"2000-08-08\")";
<!-- Change 'admin' to the admin's name, he is not in the contest -->
$users = $DB_site->query(
"SELECT post.userid, count(post.userid) as count, user.username from " .
"post, user WHERE post.dateline >= $date1 and post.dateline <= $date2 " .
"and post.userid = user.userid and user.username <> 'admin' group ".
"by post.userid order by count DESC");
<!-- Change 'admin' to the admin's name -->
$admin = $DB_site->query(
"SELECT post.userid, count(post.userid) as count, user.username from " .
"post, user WHERE post.dateline >= $date1 and post.dateline <= $date2 " .
"and post.userid = user.userid and user.username = 'admin' group ".
"by post.userid order by count DESC");
<!-- Put your header in here
This is mine
include("/usr/local/zeus/web_roots/main/www.hedgehogwheels.com/menu.html") ?>
-->
<p><a href="./"><img border="0" src="images/bbtitle.gif" width="420" height="85"></a></p>
<p align="center"><b><font face="verdana,arial,helvetica" size="2">The User who
posts the most on-topic posts from July 8th, 2000 to Aug 8th 2000 will receive a
free Hedgehog wheel. International winners must pay their own s/h costs.</font></b></p>
<div align="center">
<table border="1" cellpadding="4" cellspacing="4">
<tr>
<td bgcolor="#9900CC"><b><font face="verdana,arial,helvetica" color="#FFFFFF" size="3">User</font></b></td>
<td bgcolor="#9900CC"><b><font face="verdana,arial,helvetica" size="3"><font
color="#FFFFFF">Posts
from July 8th to Aug 8th</font></font></b></td>
</tr>
<tr>
<td>
<FONT face="verdana,arial,helvetica" size="2">
<br>
<?php
while ($user = $DB_site->fetch_array($users))
{
$username = $user["username"];
echo ("$username<br>");
}
echo ("<br>");
while ($user = $DB_site->fetch_array($admin))
{
$username = $user["username"];
echo ("$username<br>");
}
?>
<br>
</font>
</td>
<td align="center">
<FONT face="verdana,arial,helvetica" size="2">
<br>
<?php
$DB_site->data_seek(0,$users);
while ($user = $DB_site->fetch_array($users))
{
$count = $user["count"];
echo ("$count<br>");
}
echo ("<br>");
$DB_site->data_seek(0,$admin);
while ($user = $DB_site->fetch_array($admin))
{
$count = $user["count"];
echo ("$count<br>");
}
?>
<br>
</font>
</td>
</tr>
</table>
</div>
<p> </p>
<!-- Put any Footer info in here
This Is Mine
<?php
include ("/usr/local/zeus/web_roots/main/www.hedgehogwheels.com/menu.html");
include("/usr/local/zeus/web_roots/main/www.hedgehogwheels.com/meter.html");
?>
-->
</body>
</html>
This code goes in global.php right before
eval("\$fivelinks = \"".gettemplate("fivelinks")."\";");
What this does is make the Current Top Poster available in the Fivelinks Template.
Code:
$date1 = "UNIX_TIMESTAMP(\"2000-07-08\")";
$date2 = "UNIX_TIMESTAMP(\"2000-08-08\")";
$pusers = $DB_site->query(
"SELECT post.userid, count(post.userid) as count, user.username from " .
"post, user WHERE post.dateline >= $date1 and post.dateline <= $date2 " .
"and post.userid = user.userid and user.username <> 'freddie' group ".
"by post.userid order by count DESC");
$puser = $DB_site->fetch_array($pusers);
$pusername = $puser["username"];
$pusercount = $puser["count"];
$puser is the top poster and $pusercount is the number of posts. Put those two variables in fivelinks and format it as you wish and you will see the current leader (through the dates you specified) on every page at the top. Make sure to again change 'admin' to the admin's name unless you want the admin to possibly be in the lead and in that case you take that part out all of the code above. Also change the dates to match what you put in the stats.php file. You also make a link in the fivelinks template to 'stats.php' so users can open it and see the current list of posters for the time period.
There ya go and remember I did this only for myself so it is rough but works for me. I hope you can make it work for you.
[Edited by rangersfan on 07-15-2000 at 02:06 AM]
Bookmarks