modify Top List module to not include dev accounts

General Chat, Comments
Post Reply
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

modify Top List module to not include dev accounts

Post by cbsarge »

I'm trying to modify the top_list module to not display the first 4 player IDs. Those are developer accounts and their stats are a little ridiculous so I'd rather it only list the real players. How would I modify this query?

Code: Select all

$result = $db->Execute("select id,name from user_stat_types where max_value is null and display_code is null order by name");
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: modify Top List module to not include dev accounts

Post by KyleMassacre »

Well you would need the query that selects the user id from the stats and gets the names from the users table. In there you can add something like:

Code: Select all

$array = array(2,3,4,5);
//the db query is here and the loop while(!$result->EOF) {
    if(!in_array($array,$result->id)
    {
        //print the contents
    }
    $result->MoveNext();
//} end of the loop
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

Re: modify Top List module to not include dev accounts

Post by cbsarge »

Hmmm... after much monkeying around I still am unable to get the results to not list the IDs in the array. :oops:

Code: Select all

<?php
$array = array(2,3,4);
$result = $db->Execute("select id,name from user_stat_types where max_value is null and display_code is null order by name");
$statNames = array();
$nb = array($db->Execute("select id from users"));
while (! $result->EOF)
{
	$statNames[$result->fields[0] + 0] = $result->fields[1];
	$result->MoveNext();
}
$result->Close();

echo "<table class='plainTable'>";
echo "<tr valign='top'>";
foreach ($statNames as $statId => $statName)
{
    echo "<td>";
    TableHeader($statName);
    echo "<table class='plainTable'>";
    $result = $db->Execute("select users.username, user_stats.value from user_stats left join users on users.id = user_stats.user_id where stat_type = ? order by value desc limit 0,50", $statId);
    $l = 0;
    while (! $result->EOF)
    {
    if(!in_array($array,$nb))
    {
		if ($l % 2 == 0)
            echo "<tr class='evenLine'>";
        else
            echo "<tr class='oddLine'>";
        echo "<td>{$result->fields[0]}</td><td>{$result->fields[1]}</td>";
        echo "</tr>";
	}
        $result->MoveNext();
        $l ++;
    }
    echo "</table>";
    TableFooter();
    echo "</td>";
}
echo "</tr>";
echo "</table>";
?>
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: modify Top List module to not include dev accounts

Post by KyleMassacre »

Try:

Code: Select all

<?php
$array = array(2,3,4);
$result = $db->Execute("select id,name from user_stat_types where max_value is null and display_code is null order by name");
$statNames = array();
while (! $result->EOF)
{
    $statNames[$result->fields[0] + 0] = $result->fields[1];
    $result->MoveNext();
}
$result->Close();

echo "<table class='plainTable'>";
echo "<tr valign='top'>";
foreach ($statNames as $statId => $statName)
{
    echo "<td>";
    TableHeader($statName);
    echo "<table class='plainTable'>";
    $result = $db->Execute("select users.username, user_stats.value, users.id from user_stats left join users on users.id = user_stats.user_id where stat_type = ? order by value desc limit 0,50", $statId);
    $l = 0;
    while (! $result->EOF)
    {
        if(!in_array($array,$result->id))
        {
            if ($l % 2 == 0)
                echo "<tr class='evenLine'>";
            else
                echo "<tr class='oddLine'>";
            echo "<td>{$result->fields[0]}</td><td>{$result->fields[1]}</td>";
            echo "</tr>";
        }
        $result->MoveNext();
        $l ++;
    }
    echo "</table>";
    TableFooter();
    echo "</td>";
}
echo "</tr>";
echo "</table>";
?>
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

Re: modify Top List module to not include dev accounts

Post by cbsarge »

Error: Un-handled Exception: Can't get property id.
Error in "/hermes/bosnaweb03a/b2751/ipg.cbsargecom/VillainsandHeroes/libs/db.php"
Line 428
Error in /hermes/bosnaweb03a/b2751/ipg.cbsargecom/VillainsandHeroes/libs/common.php
Line 554
Error in /hermes/bosnaweb03a/b2751/ipg.cbsargecom/VillainsandHeroes/index.php
Line 331
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: modify Top List module to not include dev accounts

Post by KyleMassacre »

Oops that's my lame fault, rookie mistake. For the "in_array()" change it to $result->fields[2] instead of $result->id
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

Re: modify Top List module to not include dev accounts

Post by cbsarge »

that caused a error saying I provided an integer and it was expecting an array. :|

Code: Select all

Error: in_array() expects parameter 2 to be array, integer given
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: modify Top List module to not include dev accounts

Post by KyleMassacre »

My bad again. I got the needle and haystack messed up. Switch the parameters around in the in_array()
User avatar
cbsarge
Posts: 195
Joined: Mon Sep 14, 2015 3:20 pm

Re: modify Top List module to not include dev accounts

Post by cbsarge »

That fixed it - thanks for all the help Kyle!
Post Reply

Return to “General”