Jump to content

[php]looking for Help : order by


Recommended Posts

Posted

Hello,

i'm a total noob in php and i try to write a simple script for arena ranking for my website.

So i start to modify the script that i've found on the post-it in this section and it's working pretty well but,

i want to change the / ORDER BY `name` / by `rating`

$sql = mysql_query("SELECT * FROM `arena_team_stats` ORDER BY `rating` DESC LIMIT 0, 10");
echo "<center><table border=0 width=70%>
<tr>
<td>Team Name</td>
<td>Faction</td>
<td align=center>Type</td>
<td align=center>Rating</td>
</tr>";
while ($row = mysql_fetch_array($sql)){
$query_num = mysql_query("SELECT COUNT(*) FROM `arena_team_member` WHERE `arenateamid`='$row[arenateamid]'");
$gleader = "SELECT name,race FROM `characters` WHERE `guid`='$row[captainguid]'";
$myrow = mysql_fetch_array(mysql_query($gleader));
$top = mysql_query("SELECT * FROM `arena_team_stats` WHERE `arenateamid`='$row[arenateamid]'");
$toprow = mysql_fetch_array($top);
if($myrow['race']=="1" or $myrow['race']=="3" or $myrow['race']=="4" or $myrow['race']=="7" or  $myrow['race']=="11"){
   $faction = "alliance";
   }else{
   $faction = "horde";}
echo "
<tr>
<td >
<p style='padding-left: 5px'>[url='?guid=".$row[arenateamid]."']".$row['name']."[/url]</p>
</td>
<td align=center><center><img src=images/".$faction.".gif title=".$faction."></center></td>
<td  align=center><center>".$teamType[$row['type']]."</center></td>
<td align=right><p style='padding-right: 8px'>".$toprow['rating']."</p></td></tr>";
}

So i got this but since the capitainguid isn't in my table `arena_team_stats` how can i do it ?

Posted

$query_num = mysql_query("SELECT COUNT(*) FROM `arena_team_member` WHERE `arenateamid`='$row[arenateamid]'");

try to change $query_num = mysql_query("SELECT COUNT(*) FROM `arena_team_member` WHERE `arenateamid`=$row['arenateamid']");

×
×
  • 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. Privacy Policy Terms of Use