Jump to content

Can't fetch a certain data in mysql for some reason.


dezkit

Recommended Posts

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

 

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.