Code showing double?? a little help please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Code showing double?? a little help please

Post by boondox »


Ok the code I have here Lists the members in a clan within the game..It is working the way it is supposed to..

However the Clan Leader sees a ghost empire in the clan list..


How do I eliminate the ghost?


Code: Select all

print "
<table width=60% bgcolor=#333333 border=1>\n";
         print "<caption>Empire List</caption>";
         $dball = mysql_db_query($dbname,"select empire,num,forces from $playerdb where alliance='$users[alliance]';");
         do {
            $allnum += 1;
            $listally = mysql_fetch_row($dball);
            $num = $listally[1];
            $ally = mysql_fetch_row(mysql_db_query($dbname,"select networth,rank from $playerdb where num='$num';"));
                        $infantry = mysql_fetch_row(mysql_db_query($dbname,"select infantry from $playerdb where num='$num';"));
                        $race2 = mysql_fetch_row(mysql_db_query($dbname,"select race2 from $playerdb where num='$num';"));
                        $tanks = mysql_fetch_row(mysql_db_query($dbname,"select tanks from $playerdb where num='$num';"));
                        $helis = mysql_fetch_row(mysql_db_query($dbname,"select helis from $playerdb where num='$num';"));
                        $ships = mysql_fetch_row(mysql_db_query($dbname,"select ships from $playerdb where num='$num';"));
                        $turns = mysql_fetch_row(mysql_db_query($dbname,"select turns from $playerdb where num='$num';"));
            $land = mysql_fetch_row(mysql_db_query($dbname,"select land from $playerdb where num='$num';"));
                        $runes = mysql_fetch_row(mysql_db_query($dbname,"select runes from $playerdb where num='$num';"));
                        $wizards = mysql_fetch_row(mysql_db_query($dbname,"select wizards from $playerdb where num='$num';"));
                        $ally[0] = commas($ally[0]);
            if ($users[num] == $alliance[founder]) {
               print "
<TR><TD bgcolor=#000000>$listally[0] (#$listally[1])</td>
<TD bgcolor=#000000>Networth: \$$ally[0]</td>
<TD bgcolor=#000000>Land: $land[0]</td>
<TD bgcolor=#000000 align=center>Rank: $ally[1]</TD></tr>
<tr><TD bgcolor=#000000>Infantry: $infantry[0]</td>
<TD bgcolor=#000000>Catapults: $tanks[0]</td>
<TD bgcolor=#000000>Dragons: $helis[0]</td>
<TD bgcolor=#000000>Ships: $ships[0]</td></tr>
<tr><TD bgcolor=#000000>Race: $race2[0]</td>
<TD bgcolor=#000000>Turns: $turns[0]</td>
<TD bgcolor=#000000>Priests: $wizards[0]</td>";
               if ($listally[2] == "1") { print "<TD align=center bgcolor=#000000><font color=lime>Sharing: YES</font></TD></TR></tr><tr><td colspan=4><center>&nbsp</center></td></tr>"; }
               else {print "<TD bgcolor=#000000 align=center><font color=red>Sharing: NO</font></TD></TR><tr><td colspan=4><center>&nbsp</center></td></tr>"; }
            } elseif ($listally[1] != "") {
               print "
<TR><TD bgcolor=#000000>$listally[0] (#$listally[1])</td>
<TD bgcolor=#000000>Networth: \$$ally[0]</td>
<TD bgcolor=#000000>Land: $land[0]</td>
<TD bgcolor=#000000 align=center>Rank: $ally[1]</TD>";
               if ($listally[2] == "1") { print "<TD align=center bgcolor=#000000><font color=lime>Sharing: YES</font></TD></TR></tr><tr><td colspan=4><center>&nbsp</center></td></tr>"; }
               else {print "<TD bgcolor=#000000 align=center><font color=red>Sharing: NO</font></TD></TR><tr><td colspan=4><center>&nbsp</center></td></tr>"; }
            } 
         } while ($listally[1] != "");
         print "</table><br>\n";
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Code showing double?? a little help please

Post by requinix »

boondox wrote:How do I eliminate the ghost?
Exorcise?

What's a "ghost empire"?

Oh, and your code scares me.
Last edited by requinix on Mon Oct 20, 2008 9:49 pm, edited 1 time in total.
boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Re: Code showing double?? a little help please

Post by boondox »

Ok let me elaborate a bit more...


The table that shows the clans empires is showing the Table rows and columns to indicate another empire within the clan...

However it is NOT showing any of the empires Info.. (because the empire does not exist)


Ok so In my beta test clan I have 2 empires.. Yet the list shows 3 empires the third being a ghost (non-existent empire)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Code showing double?? a little help please

Post by requinix »

Run the

Code: Select all

select empire,num,forces from $playerdb where alliance='$users[alliance]
query yourself (after filling in the blanks) and see if you get 2 or 3 results.
boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Re: Code showing double?? a little help please

Post by boondox »

yeah still getting the ghost empire stats


I'm thinking I didn't end a statement right or something...
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Code showing double?? a little help please

Post by requinix »

boondox wrote:yeah still getting the ghost empire stats
I'm thinking I didn't end a statement right or something...
Not sure you understood what I meant.
I mean take that query, put in some values, and run it in something like phpMyAdmin or a MySQL client.
boondox
Forum Newbie
Posts: 20
Joined: Wed Oct 08, 2008 4:58 am

Re: Code showing double?? a little help please

Post by boondox »

Ok look here is the code as it was BEFORE I changed it...

It works perfectly like this

Code: Select all

        print "
<table width=60% bgcolor=#333333 border=1>
<TR bgcolor=#222222>
<TD>Ally</TD>
<TD>Networth</TD>
<td align=center>Rank</TD>
<TD align=center>Sharing</TD>
</TR>\n";
            print "<caption>Empire List</caption>";
            $dball = mysql_db_query($dbname,"select empire,num,forces from $playerdb where alliance='$users[alliance]';");
            do {
                $allnum += 1;
                $listally = mysql_fetch_row($dball);
                $num = $listally[1];
                $ally = mysql_fetch_row(mysql_db_query($dbname,"select networth,rank from $playerdb where num='$num';"));
                $ally[0] = commas($ally[0]);
                if ($listally[1] != "") {
                    print "
<TR><TD bgcolor=#000000>$listally[0] (#$listally[1])</td>
<TD bgcolor=#000000>\$$ally[0]</td>
<TD bgcolor=#000000 align=center>$ally[1]</TD>";
                    if ($listally[2] == "1") { print "<TD align=center bgcolor=#000000><font color=lime>YES</font></TD></TR>"; }
                    else {print "<TD bgcolor=#000000 align=center><font color=red>NO</font></TD></TR>"; }
                }
            } while ($listally[1] != "");
            print "</table><br>\n";

I changed it to this because I want the Clan Leader to see more about his members than other members of the clan...

Code: Select all

print "
<table width=60% bgcolor=#333333 border=1>\n";
print "<caption>Empire List</caption>";
$dball = mysql_db_query($dbname,"select empire,num,forces from $playerdb where alliance='$users[alliance]';");
do {
$allnum += 1;
$listally = mysql_fetch_row($dball);
$num = $listally[1];
$ally = mysql_fetch_row(mysql_db_query($dbname,"select networth,rank from $playerdb where num='$num';"));
$infantry = mysql_fetch_row(mysql_db_query($dbname,"select infantry from $playerdb where num='$num';"));
$race2 = mysql_fetch_row(mysql_db_query($dbname,"select race2 from $playerdb where num='$num';"));
$tanks = mysql_fetch_row(mysql_db_query($dbname,"select tanks from $playerdb where num='$num';"));
$helis = mysql_fetch_row(mysql_db_query($dbname,"select helis from $playerdb where num='$num';"));
$ships = mysql_fetch_row(mysql_db_query($dbname,"select ships from $playerdb where num='$num';"));
$turns = mysql_fetch_row(mysql_db_query($dbname,"select turns from $playerdb where num='$num';"));
$land = mysql_fetch_row(mysql_db_query($dbname,"select land from $playerdb where num='$num';"));
$runes = mysql_fetch_row(mysql_db_query($dbname,"select runes from $playerdb where num='$num';"));
$wizards = mysql_fetch_row(mysql_db_query($dbname,"select wizards from $playerdb where num='$num';"));
$ally[0] = commas($ally[0]);
if ($users[num] == $alliance[founder]) {
print "
<TR><TD bgcolor=#000000>$listally[0] (#$num)</td>
<TD bgcolor=#000000>Networth: \$$ally[0]</td>
<TD bgcolor=#000000>Land: $land[0]</td>
<TD bgcolor=#000000 align=center>Rank: $ally[1]</TD></tr>
<tr><TD bgcolor=#000000>Infantry: $infantry[0]</td>
<TD bgcolor=#000000>Catapults: $tanks[0]</td>
<TD bgcolor=#000000>Dragons: $helis[0]</td>
<TD bgcolor=#000000>Ships: $ships[0]</td></tr>
<tr><TD bgcolor=#000000>Race: $race2[0]</td>
<TD bgcolor=#000000>Turns: $turns[0]</td>
<TD bgcolor=#000000>Priests: $wizards[0]</td>";
if ($listally[2] == "1") { print "<TD align=center bgcolor=#000000><font color=lime>Sharing: YES</font></TD></TR>";
print "</tr><tr><td colspan=5><center>&nbsp</center></td></tr>"; }
else {print "<TD bgcolor=#000000 align=center><font color=red>Sharing: NO</font></TD></TR>";
print "<tr><td colspan=5><center>&nbsp</center></td></tr>"; }
} elseif ($listally[1] != "") {
print "
<TR><TD bgcolor=#000000>$listally[0] (#$num)</td>
<TD bgcolor=#000000>Networth: \$$ally[0]</td>
<TD bgcolor=#000000>Land: $land[0]</td>
<TD bgcolor=#000000 align=center>Rank: $ally[1]</TD>";
if ($listally[2] == "1") { print "<TD align=center bgcolor=#000000><font color=lime>Sharing: YES</font></TD></TR></tr>";
print "<tr><td colspan=5><center>&nbsp</center></td></tr>"; }
else {print "<TD bgcolor=#000000 align=center><font color=red>Sharing: NO</font></TD></TR>";
print "<tr><td colspan=5><center>&nbsp</center></td></tr>n"; }
} 
} while ($listally[1] != "");
print "</table><br>";

Ok As I said the code does what it is supposed to do as far as allowing the Clan Leader see all the extra information and limiting regular members to the basics...


However the clan leader sees this

Code: Select all

 
Clan Member(1)--Ect Ect Ect..Yada Yada Yada
Clan Member(2)--Ect Ect Ect..Yada Yada Yada
Clan Member(3)--Ect Ect Ect..Yada Yada Yada
 
then a ghost member...  meaning  just the table rows  and columns  with No Information..
 
 

so for some reason My code changes are not ending the script in the right place.. the script is supposed to end after the last clan member is listed..
Post Reply