Jump to content
MakeWebGames

Recommended Posts

Posted

well here is my hall of fame I think it is the basic one, I need help

selecting from attacklogs where result =won, and listing the top in my

attack logs it has the following fields attacker, attacked, result that

would be needed for this can anyone help? ;(

 

   <?php
include "globals.php";
$filters=array(
'nodon' => 'AND donatordays=0',
'don' => 'AND donatordays > 0',
'all' => '');
$filter=(isset($filters[$_GET['filter']])) ? $_GET['filter'] : 'all';
$myf=$filters[$filter];
$bt1=($filter=="nodon") ? "[b]" : "";
$bet1=($filter=="nodon") ? "[/b]" : "";
$bt2=($filter=="don") ? "[b]" : "";
$bet2=($filter=="don") ? "[/b]" : "";
$bt3=($filter=="all") ? "[b]" : "";
$bet3=($filter=="all") ? "[/b]" : "";
print "<h2>Hall Of Fame</h2><hr />
<table width=65% cellspacing=1 class='table'> 
<tr> 
<td>[url='halloffame.php?action=level&filter={$filter}']LEVEL[/url]</td> 
<td>[url='halloffame.php?action=money&filter={$filter}']MONEY[/url]</td> 
<td>[url='halloffame.php?action=respect&filter={$filter}']RESPECT[/url]</td> 

</tr>
<tr> 

<td>[url='halloffame.php?action=agility&filter={$filter}']AGILITY[/url]</td> 

<td>[url='halloffame.php?action=labour&filter={$filter}']LABOUR[/url]</td> 
<td>[url='halloffame.php?action=iq&filter={$filter}']IQ[/url]</td> </tr> 
<tr><td> </td><td>[url='halloffame.php?action=rcelogs&filter={$filter}']LAST 25 RACE RESULTS[/url]</td><td> </td></tr></table>";

switch($_GET['action'])
{
case "level":
hof_level();
break;
case "attacks":
hof_attackswon();
break;
case "money":
hof_money();
break;
case "points":
hof_points();
break;
case "respect":
hof_respect();
break;
case "total":
hof_total();
break;
case "strength":
hof_strength();
break;
case "agility":
hof_agility();
break;
case "guard":
hof_guard();
break;
case "labour":
hof_labour();
break;
case "iq":
hof_iq();
break;
case "referal":
hof_referals();
break;
case 
"rcelogs": 
view_race_logs(); 
break;
}
function view_race_logs()
{
global $db,$ir,$c,$h,$userid;
print "<h3>Race Logs</h3>
<table width=65% cellspacing='1' class='table'> <tr style='background:gray'> <th>ID</th> <th>User From</th> <th>User To</th> <th></th> <th>Amount</th> <th>Winner</th> <th></th> </tr>";
$q=$db->query("SELECT rr.*,u1.username as sender, u2.username as sent FROM race_results rr LEFT JOIN users u1 ON rr.rrCHALLENGER=u1.userid LEFT JOIN users u2 ON rr.rrCHALLENGED=u2.userid ORDER BY rr.rrID ASC LIMIT 25");
while($r=$db->fetch_row($q))
{
if($r['cxFROMIP'] == $r['cxTOIP']) { $m="<span style='color:red;font-weight:800'>MULTI</span>"; } else { $m=""; }
print "<tr><td>{$r['rrID']}</td> <td>[url='viewuser.php?u={$r[']{$r['sender']}[/url] [{$r['rrCHALLENGER']}] 
[b]Used [{$r['rrCHRCAR']}] [/b] </td><td>[url='viewuser.php?u={$r[']{$r['sent']}[/url] [{$r['rrCHALLENGED']}] 
[b] Used [{$r['rrCHDCAR']}] [/b] </td> <td></td> <td> {$r['rrBET']} Money </td> <td>{$r['rrWINNER']} </td> <td></td> </tr>";
}
print "</table>";
stafflog_add("Viewed the Race Logs");
}
function hof_level()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the 20 users with the highest levels

<table width=65% cellspacing=1 class='table'><tr style='background:gray'> <th>Pos</th> <th>User</th> <th>Level</th> </tr>";
$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY level DESC,userid ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['userid'] == $userid) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['gangPREF']} {$r['username']} [{$r['userid']}]$et</td> <td>$t{$r['level']}$et</td> </tr>";
}
print "</table>";
}
function hof_money()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the 20 users with the highest amount of money

<table width=65% cellspacing=1 class='table'><tr style='background:gray'> <th>Pos</th> <th>User</th> <th>Money</th> </tr>";
$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY money DESC,userid ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['userid'] == $userid) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['gangPREF']} {$r['username']} [{$r['userid']}]$et</td> <td>$t\$".money_formatter($r['money'],'')."$et</td> </tr>";
}
print "</table>";
}
function hof_points()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the 20 users with the highest amount of points

<table width=65% cellspacing=1 class='table'><tr style='background:gray'> <th>Pos</th> <th>User</th> <th>points</th> </tr>";
$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY points DESC,userid ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['userid'] == $userid) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['gangPREF']} {$r['username']} [{$r['userid']}]$et</td> <td>$t".money_formatter($r['points'],'')."$et</td> </tr>";
}
print "</table>";
}

function hof_respect()
{
global $db,$ir,$c,$userid;
print "Showing the 20 gangs with the highest amount of respect

<table width=65% cellspacing=1 class='table'><tr style='background:gray'> <th>Pos</th> <th>Gang</th> <th>Respect</th> </tr>";
$q=$db->query("SELECT * FROM gangs ORDER BY gangRESPECT DESC,gangID ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['gangID'] == $ir['gang']) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['gangNAME']} [{$r['gangID']}]$et</td> <td>$t".money_formatter($r['gangRESPECT'],'')."$et</td> </tr>";
}
print "</table>";
}

function hof_total()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the 20 users with the highest total stats

<table width=65% cellspacing=1 class='table'><tr style='background:gray'> <th>Pos</th> <th>User</th> </tr>";
$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY (us.strength+us.agility+us.guard+us.labour+us.IQ) DESC,u.userid ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['userid'] == $ir['userid']) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['gangPREF']} {$r['username']} [{$r['userid']}]$et</td> </tr>";
}
print "</table>";
}
function hof_strength()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the 20 users with the highest strength

<table width=65% cellspacing=1 class='table'><tr style='background:gray'> <th>Pos</th> <th>User</th> </tr>";
$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY us.strength DESC,u.userid ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['userid'] == $ir['userid']) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['gangPREF']} {$r['username']} [{$r['userid']}]$et</td> </tr>";
}
print "</table>";
}
function hof_agility()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the 20 users with the highest agility

<table width=65% cellspacing=1 class='table'><tr style='background:gray'> <th>Pos</th> <th>User</th> </tr>";
$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY us.agility DESC,u.userid ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['userid'] == $ir['userid']) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['gangPREF']} {$r['username']} [{$r['userid']}]$et</td> </tr>";
}
print "</table>";
}
function hof_guard()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the 20 users with the highest guard

<table width=65% cellspacing=1 class='table'><tr style='background:gray'> <th>Pos</th> <th>User</th> </tr>";
$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY us.guard DESC,u.userid ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['userid'] == $ir['userid']) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['gangPREF']} {$r['username']} [{$r['userid']}]$et</td> </tr>";
}
print "</table>";
}
function hof_labour()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the 20 users with the highest labour

<table width=65% cellspacing=1 class='table'><tr style='background:gray'> <th>Pos</th> <th>User</th> </tr>";
$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY us.labour DESC,u.userid ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['userid'] == $ir['userid']) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['gangPREF']} {$r['username']} [{$r['userid']}]$et</td> </tr>";
}
print "</table>";
}
function hof_iq()
{
global $db,$ir,$c,$userid, $myf;
print "Showing the 20 users with the highest IQ

<table width=65% cellspacing=1 class='table'><tr style='background:gray'> <th>Pos</th> <th>User</th> </tr>";
$q=$db->query("SELECT u.*,g.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN gangs g ON g.gangID=u.gang WHERE u.user_level != 0 $myf ORDER BY us.IQ DESC,u.userid ASC LIMIT 20");
$p=0;
while($r=$db->fetch_row($q))
{
$p++;
if($r['userid'] == $ir['userid']) { $t="[b]";$et="[/b]"; } else { $t="";$et=""; }
print "<tr> <td>$t$p$et</td> <td>$t{$r['gangPREF']} {$r['username']} [{$r['userid']}]$et</td> </tr>";
}
print "</table>";
}


$h->endpage(); ?>
Posted

There are a number of ways of doing this.

Since you're having trouble with it, I would suggest the simplest; create a new variable in the users table called attackswon (int 11). Then do a search of all your files, and wherever a new attacklogs entry is added with result=won, also increment the counter in the users table for that user. Then adding it to the hall of fame would be easy.

To make this retroactive, run a script that cycles through you entire attack logs table, and adds +1 to the variable in the users table for each result=won.

Posted

well that is a good idea but I know there has got to be a way to do a select count or num rows with a left join users and some way to order by with a limit of, now that is the tricky part :D I was wondering if anyone could do it? Cause I know it is beyond me as of now!

I think I am close with this one but I am still doing tons of trial and error to get my queries so I am not sure :D[mysql]mysql_query("SELECT COUNT(*) FROM attacklogs al LEFT JOIN users u ON u.userid = al.attacker WHERE al.result = 'won' ORDER BY COUNT(*) DESC");[/mysql]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...