Page 1 of 1
Code showing double?? a little help please
Posted: Mon Oct 20, 2008 9:10 pm
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> </center></td></tr>"; }
else {print "<TD bgcolor=#000000 align=center><font color=red>Sharing: NO</font></TD></TR><tr><td colspan=4><center> </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> </center></td></tr>"; }
else {print "<TD bgcolor=#000000 align=center><font color=red>Sharing: NO</font></TD></TR><tr><td colspan=4><center> </center></td></tr>"; }
}
} while ($listally[1] != "");
print "</table><br>\n";
Re: Code showing double?? a little help please
Posted: Mon Oct 20, 2008 9:43 pm
by requinix
boondox wrote:How do I eliminate the ghost?
Exorcise?
What's a "ghost empire"?
Oh, and your code scares me.
Re: Code showing double?? a little help please
Posted: Mon Oct 20, 2008 9:48 pm
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)
Re: Code showing double?? a little help please
Posted: Mon Oct 20, 2008 9:50 pm
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.
Re: Code showing double?? a little help please
Posted: Mon Oct 20, 2008 10:03 pm
by boondox
yeah still getting the ghost empire stats
I'm thinking I didn't end a statement right or something...
Re: Code showing double?? a little help please
Posted: Mon Oct 20, 2008 10:15 pm
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.
Re: Code showing double?? a little help please
Posted: Tue Oct 21, 2008 12:31 am
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> </center></td></tr>"; }
else {print "<TD bgcolor=#000000 align=center><font color=red>Sharing: NO</font></TD></TR>";
print "<tr><td colspan=5><center> </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> </center></td></tr>"; }
else {print "<TD bgcolor=#000000 align=center><font color=red>Sharing: NO</font></TD></TR>";
print "<tr><td colspan=5><center> </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..