Re: multidimensional array problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ive followed your example on grouping. Im still trying to understand all of the code but ive made great progess on this with your example. Now I have one last issue and this will be solved. Ill remind here what Im trying to achieve I have a table for leagues, lookup table and team roster. There can be multiple game types for each game i.e. CoD2 - CTF, CoD2 - S&D, CoD2 - TDM. If a member is playing CoD2 CTF and CoD2 TDM there should be a table for each game and type showing each member playing that game/type. If a member is signed up for multiple games/types he/she should have a name listed under each game/type.

Right now my php script is only sorting by game which is putting the same person in for each instance of the game instead of sorting through each game and then type. So here is my code so far and any help is greatly appreciated.

<?php
include ("db.php");

$memroster = "SELECT inf_league.game, inf_league.type, inf_member.user_name, inf_member.rank, " .
           "inf_member.country, inf_member.email " .
           "FROM inf_league " .
"INNER JOIN inf_memberleague ON inf_league.gid = inf_memberleague.l_id " . "INNER JOIN inf_member ON inf_member.user_id = inf_memberleague.m_id";
$roster = array();
$memrosterresults = mysql_query($memroster)
or die(mysql_error());
while ($record = mysql_fetch_object($memrosterresults)) {
$roster[$record->game][] = $record;
}
ksort($roster);
foreach ($roster as $game => $records) {
  print "<table>\n";
  print "<caption>{$game}</caption>\n";
  print "<th>Name</th> <th>Rank</th> <th>Country</th> <th>Email</th>\n";
  foreach ($records as $record) {
    print "<tr>\n";
    print "<td>{$record->user_name}</td>\n";
 print "<td>{$record->rank}</td>\n";
 print "<td>{$record->country}</td>\n";
 print "<td>{$record->email}</td>\n";
 print "</tr>\n";
   }
print "</table>\n";
}
?>

_________________________________________________________________
Valentine?s Day -- Shop for gifts that spell L-O-V-E at MSN Shopping http://shopping.msn.com/content/shp/?ctId=8323,ptnrid=37,ptnrdata=24095&tcode=wlmtagline

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux