omni Posted March 10, 2009 Share Posted March 10, 2009 Ok as you can see in the image below I have a loop problem somewhere in my code.. However I myself just cannot figure out where my error is.. I hope someone else can help me solve this issue print " <table width=80% background=imgs/bg.jpg border=1 bordercolor=black>\n"; print "<caption>Empire List</caption>"; $dball = mysql_db_query($dbname,"select empire,num 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]); $yah = mysql_fetch_row(mysql_db_query($dbname,"select yah from $playerdb where num='$num';")); $msn = mysql_fetch_row(mysql_db_query($dbname,"select msn from $playerdb where num='$num';")); $icq = mysql_fetch_row(mysql_db_query($dbname,"select icq from $playerdb where num='$num';")); $aim = mysql_fetch_row(mysql_db_query($dbname,"select aim from $playerdb where num='$num';")); if ($users[num] == $alliance[founder]) { print " <TR><TD>$listally[0] (#$listally[1])</td> <TD>Networth: \$$ally[0]</td> <TD>Land: $land[0]</td> <TD>Rank: $ally[1]</TD></tr> <tr><TD>Infantry: $infantry[0]</td> <TD>Catapults: $tanks[0]</td> <TD>Dragons: $helis[0]</td> <TD>Ships: $ships[0]</td></tr> <tr><td>Yahoo: $yah[0]</td><td>MSN: $msn[0]</td><td>ICQ: $icq[0]</td><td>AIM: $aim[0]</td></tr> <tr><TD>Race: $race2[0]</td> <TD>Turns: $turns[0]</td> <TD>Priests: $wizards[0]</td>"; if ($listally[2] == "1") { print "<TD bgcolor=black><font color=lime>Sharing: YES</font></TD></TR>"; print "</tr><tr><td colspan=5><center><hr></center></td></tr>"; } else {print "<TD bgcolor=black><font color=red>Sharing: NO</font></TD></TR>"; print "<tr><td colspan=5><center><hr></center></td></tr>"; } } elseif ($listally[1] != "") { print " <TR><TD>$listally[0] (#$listally[1])</td> <TD>Networth: \$$ally[0]</td> <TD>Land: $land[0]</td> <TD>Rank: $ally[1]</TD>"; if ($listally[2] == "1") { print "<TD bgcolor=black><font color=lime>Sharing: YES</font></TD></TR></tr>"; print "<tr><td>Yahoo: $yah[0]</td><td>MSN: $msn[0]</td><td>ICQ: $icq[0]</td><td>AIM: $aim[0]</td></tr>"; print "<tr><td colspan=5><center><hr></center></td></tr>"; } else {print "<TD bgcolor=black><font color=red>Sharing: NO</font></TD></TR>"; print "<tr><td>Yahoo: $yah[0]</td><td>MSN: $msn[0]</td><td>ICQ: $icq[0]</td><td>AIM: $aim[0]</td></tr>"; print "<tr><td colspan=5><center><hr></center></td></tr>"; } } } while ($listally[1] != ""); print "</table><br>\n"; if ($users[num] == $alliance[founder]) { print "<input class=button type=submit name=RemoveMe value=\"Leave Clan\">\n"; print "<br><input type=text name=number3 size=4 class=input> <input class=button type=submit name=RemoveUser value=\"Remove Empire\">\n"; print "<br><input type=text name=founder size=4 class=input> <input class=button type=submit name=ChangeFounder value=\"Change Clan Leader\">\n"; print "<br><input type=text name=cofounder size=4 class=input> <input class=button type=submit name=ChangeCoFounder value=\"Change Co Leader\">\n"; print "<br><input type=text name=warminister size=4 class=input> <input class=button type=submit name=changewarminister value=\"Change War Minister\">\n"; print "<br><input type=text name=foriegnaffairs size=4 class=input> <input class=button type=submit name=changeforiegnaffairs value=\"Change Foriegn Affairs\">\n"; print "<br><input type=password name=password1 size=8 class=input><input type=password name=password2 size=8 class=input> <input class=button type=submit name=ChangePass value=\"Change Password\">\n"; print "<br>Alliance Name: <input type=text name=alliance1 value=\"$alliance[alliance]\" size=15 class=input> <input class=button type=submit name=ChangeName value=\"Change Name\">\n"; print "<br>Flag URL: <input type=text name=flag value=\"$alliance[flag]\" size=25 class=input> <input class=button type=submit name=ChangeFlag value=\"Change Flag\">\n"; print "<br>Site URL: <input type=text name=url value=\"$alliance[url]\" size=25 class=input> <input class=button type=submit name=ChangeURL value=\"Change URL\">\n"; if($alliance[msg] != "") { $alliance[msg] = preg_replace("/<br>/","\n",$alliance[msg]); } Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 10, 2009 Share Posted March 10, 2009 well...for starters, instead of do {} while(); it should be like: while($listally = mysql_fetch_row($dball)){ } but, your code is terribly inefficient. you should use JOINS so you only do one query Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.