dezkit Posted September 21, 2009 Share Posted September 21, 2009 Hello guys. I have a certain problem, I want to fetch "admintype" and "ashow" from the amx_amxadmins table, but I can't seem to get it correctly, it just shows up blank, How can i fix this problem? Here is my code: <table border=0 CELLPADDING=5> <tr> <td align=right>Alias</td> <td align=center>Dust2Pub</td> <td align=center>Deathmatch</td> <td align=center>Deathrun</td> <td align=center>Jailbreak</td> <td align=center>RPGSurf</td> <td align=center>SimpsonsFreezetag</td> <td align=center>ZombiePlague</td> <td align=center>ZombieRevolution</td> </tr> <?php $query = " SELECT admin_id, server_id, nickname, hostname, access, ashow, admintype FROM amx_amxadmins a, amx_serverinfo s, amx_admins_servers c WHERE c.admin_id = a.id AND c.server_id = s.id AND a.id = c.admin_id AND a.admintype = a.admintype ORDER BY a.admintype DESC"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $nicks[$row['nickname']][]=$row['server_id']; } $admintype = $row['admintype']; $color="1"; foreach($nicks as $nickname=>$serverids) { if($color==1){ $hello = implode(" ",$serverids); echo "<tr bgcolor='#FFF9A1'><td align=right>".$nickname."<br>"; if($admintype=="3") {echo "Owner"; }elseif($admintype=="2") {echo "Head Admin"; }elseif($admintype=="1") {echo "Server Admin";} echo "</td>"; if(strstr($hello,"4")){ // d2pub echo "<td><center><img src='http://quick-gaming.net/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://quick-gaming.net/no.gif' alt=''></center></td>"; } $color="2"; } else { $hello = implode(" ",$serverids); echo "<tr bgcolor=''><td align=right>".$nickname."<br>"; if($admintype=="3") {echo "Owner"; }elseif($admintype=="2") {echo "Head Admin"; }elseif($admintype=="1") {echo "Server Admin";} echo "</td>"; if(strstr($hello,"4")){ // d2pub echo "<td><center><img src='http://quick-gaming.net/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://quick-gaming.net/no.gif' alt=''></center></td>"; } $color="1"; } } ?> </tr> <tr> <td align=right>Alias</td> <td align=center>Dust2Pub</td> <td align=center>Deathmatch</td> <td align=center>Deathrun</td> <td align=center>Jailbreak</td> <td align=center>RPGSurf</td> <td align=center>SimpsonsFreezetag</td> <td align=center>ZombiePlague</td> <td align=center>ZombieRevolution</td> </tr> </table> Thank you! table layouts amx_amxadmins id nickname ashow admintype amx_serverinfo id hostname amx_admins_servers admin_id server_id Quote Link to comment Share on other sites More sharing options...
DavidAM Posted September 21, 2009 Share Posted September 21, 2009 while($row = mysql_fetch_array($result)){ $nicks[$row['nickname']][]=$row['server_id']; } $admintype = $row['admintype']; You are retrieving $row['admintype'] after the while loop has completed. When the loop finishes, $row will be false (not a row from the table). As a result there is no 'admintype' element (it's not an array). This is probably throwing an error (add error_reporting(E_ALL); to the beginning of the script). Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 21, 2009 Author Share Posted September 21, 2009 No error, or anything, even if I put the $row['admintype'] outside the whileloop, and foreach. Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 21, 2009 Author Share Posted September 21, 2009 Maybe I have to join it in query orsomething? Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 22, 2009 Author Share Posted September 22, 2009 bump Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 22, 2009 Author Share Posted September 22, 2009 anybody, even have an idea? Quote Link to comment Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 DavidAM is right, where you have $admintype = $row['admintype'], means it is not defined out of the while loop. Maybe alter your array in the sql query to contain admin id? $nicks[][$row['nickname'][$row['admintype']]=$row['server_id']; Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 22, 2009 Author Share Posted September 22, 2009 This is the error when I try to put that in. Fatal error: Cannot use [] for reading in /home/quickgam/public_html/dezkit.php on line 30 Quote Link to comment Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 Me and typos are like this >< $nicks[][$row['nickname']][$row['admintype']]=$row['server_id']; Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 22, 2009 Author Share Posted September 22, 2009 still doesn't work hehe, thanks for the responses though Quote Link to comment Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 Wasn't meant as a 1 line solution, sorry. The foreach will need to be rewritten to suit the array, can you post the new code used with the altered array? Someone with more array experience may have a better solution for the structure of the array also? Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 22, 2009 Author Share Posted September 22, 2009 Here: <table border=0 CELLPADDING=5> <tr> <td align=right>Alias</td> <td align=center>Dust2Pub</td> <td align=center>Deathmatch</td> <td align=center>Deathrun</td> <td align=center>Jailbreak</td> <td align=center>RPGSurf</td> <td align=center>SimpsonsFreezetag</td> <td align=center>ZombiePlague</td> <td align=center>ZombieRevolution</td> </tr> <?php $query = " SELECT admin_id, server_id, nickname, hostname, access, ashow, admintype FROM amx_amxadmins a, amx_serverinfo s, amx_admins_servers c WHERE c.admin_id = a.id AND c.server_id = s.id AND a.id = c.admin_id AND a.admintype = a.admintype ORDER BY a.admintype DESC"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $nicks[][$row['nickname']][$row['admintype']]=$row['server_id']; } $admintype = $row['admintype']; $color="1"; foreach($nicks as $nickname=>$serverids) { if($color==1){ $hello = implode(" ",$serverids); echo "<tr bgcolor='#FFF9A1'><td align=right>".$nickname."<br>"; if($admintype=="3") {echo "Owner"; }elseif($admintype=="2") {echo "Head Admin"; }elseif($admintype=="1") {echo "Server Admin";} echo "</td>"; if(strstr($hello,"4")){ // d2pub echo "<td><center><img src='http://quick-gaming.net/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://quick-gaming.net/no.gif' alt=''></center></td>"; } $color="2"; } else { $hello = implode(" ",$serverids); echo "<tr bgcolor=''><td align=right>".$nickname."<br>"; if($admintype=="3") {echo "Owner"; }elseif($admintype=="2") {echo "Head Admin"; }elseif($admintype=="1") {echo "Server Admin";} echo "</td>"; if(strstr($hello,"4")){ // d2pub echo "<td><center><img src='http://quick-gaming.net/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://quick-gaming.net/no.gif' alt=''></center></td>"; } $color="1"; } } ?> </tr> <tr> <td align=right>Alias</td> <td align=center>Dust2Pub</td> <td align=center>Deathmatch</td> <td align=center>Deathrun</td> <td align=center>Jailbreak</td> <td align=center>RPGSurf</td> <td align=center>SimpsonsFreezetag</td> <td align=center>ZombiePlague</td> <td align=center>ZombieRevolution</td> </tr> </table> Thank you Quote Link to comment Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 KK, Except my daughter needs me to get her from school... may be some hours before I get a look again... if someone else takes a looksie in the mean time, else give me a while Quote Link to comment Share on other sites More sharing options...
ozestretch Posted September 22, 2009 Share Posted September 22, 2009 Got wiggles on one monitor, notepad on the other, hope this works... This assuming the code worked, without the admin recognition. <table border=0 CELLPADDING=5> <tr> <td align=right>Alias</td> <td align=center>Dust2Pub</td> <td align=center>Deathmatch</td> <td align=center>Deathrun</td> <td align=center>Jailbreak</td> <td align=center>RPGSurf</td> <td align=center>SimpsonsFreezetag</td> <td align=center>ZombiePlague</td> <td align=center>ZombieRevolution</td> </tr> <?php $query = " SELECT admin_id, server_id, nickname, hostname, access, ashow, admintype FROM amx_amxadmins a, amx_serverinfo s, amx_admins_servers c WHERE c.admin_id = a.id AND c.server_id = s.id AND a.id = c.admin_id AND a.admintype = a.admintype ORDER BY a.admintype DESC"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $nicks[$row['nickname']][]=$row['server_id']; $admin[$row['nickname']]=$row['admintype']; } $color="1"; foreach($nicks as $nickname=>$serverids) { if($color==1){ $hello = implode(" ",$serverids); echo "<tr bgcolor='#FFF9A1'><td align=right>".$nickname."<br>"; if($admin[$nickname]=="3") {echo "Owner"; }elseif($admin[$nickname]=="2") {echo "Head Admin"; }elseif($admin[$nickname]=="1") {echo "Server Admin";} echo "</td>"; if(strstr($hello,"4")){ // d2pub echo "<td><center><img src='http://quick-gaming.net/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://quick-gaming.net/no.gif' alt=''></center></td>"; } $color="2"; } else { $hello = implode(" ",$serverids); echo "<tr bgcolor=''><td align=right>".$nickname."<br>"; if($admin[$nickname]=="3") {echo "Owner"; }elseif($admin[$nickname]=="2") {echo "Head Admin"; }elseif($admin[$nickname]=="1") {echo "Server Admin";} echo "</td>"; if(strstr($hello,"4")){ // d2pub echo "<td><center><img src='http://quick-gaming.net/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://quick-gaming.net/no.gif' alt=''></center></td>"; } $color="1"; } } ?> </tr> <tr> <td align=right>Alias</td> <td align=center>Dust2Pub</td> <td align=center>Deathmatch</td> <td align=center>Deathrun</td> <td align=center>Jailbreak</td> <td align=center>RPGSurf</td> <td align=center>SimpsonsFreezetag</td> <td align=center>ZombiePlague</td> <td align=center>ZombieRevolution</td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
dezkit Posted September 22, 2009 Author Share Posted September 22, 2009 Amazing, works like a charm, thank you very much!!!! Quote Link to comment Share on other sites More sharing options...
ozestretch Posted September 23, 2009 Share Posted September 23, 2009 Wiggles must be my inspiration Glad you got it working 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.