My mind is in a freeze, and I can't figure it out!
Here's what I have:
Tables:
users- Table with username/passwords, etc;
Data1- Table with user Posts
Data2- Table with user Posts
I want to have a contest of who posts the most in the two tables from Date1 - Date2. I can't seem to figure the logistics of this. Her'es what I have in a nut shell:
$t = "";
$sql = "SELECT * FROM users";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)){
$username = $row['username'];
$sql1= "SELECT FROM Data1, Data2 WHERE Date > 2001-05-01 AND username='$username'"
$result1 = mysql_query($sql1);
$posts = mysql_num_rows($result);
$t[$username] = "$posts";
}
// somehow sort out $t
$i = "0";
foreach($t as $username=>$posts){
if($i < 11){
echo("<b>$username</b> Has <b>$posts<b> Posts!");
}
$i++;
}
My major lack is how to sort these? And will this idea work?
Thank you for all of your help!
Alex Stanton
Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.
A bubble sort compares successive array elements and switches them if they are not in the proper order. You would compare element 0 with 1, 1 with 2, 2 with 3 etc. When no switches are necessary the array will be sorted. Or, you can use one of many standard sorting functions for arrays: go to www.php.net and look up "arrays".
Bookmarks