Im having trouble trying to modify this code so it will display duplicate data. Right now the array $playerPicks looks like 'array A', I would like it to pull the data from the database and display like 'array B'. The data is in the database. but not showing it like i would like. This is probably something simple for the more advanced, im still learning. Thank you.
Code
$sql = "select distinct weekNum from " . $db_prefix . "schedule order by weekNum;";
$query = mysql_query($sql);
$i = 0;
while ($result = mysql_fetch_array($query)) {
if ($i > 0) $weekNav .= ' | ';
if ($week !== (int)$result['weekNum']) {
$weekNav .= '<a href="results.php?week=' . $result['weekNum'] . '">' . $result['weekNum'] . '</a>';
} else {
$weekNav .= $result['weekNum'];
}
$i++;
}
$playerPicks = array();
$playerTotals = array();
$sql = "select p.userID, p.gameID, p.pickID ";
$sql .= "from " . $db_prefix . "picks p ";
$sql .= "inner join " . $db_prefix . "users u on p.userID = u.userID ";
$sql .= "inner join " . $db_prefix . "schedule s on p.gameID = s.gameID ";
$sql .= "where s.weekNum = " . $week . " and u.userName <> 'admin' ";
$sql .= "order by p.userID, s.gameTimeEastern, s.gameID";
$query = mysql_query($sql);
$i = 0;
while ($result = mysql_fetch_array($query)) {
$playerPicks[$result['userID']][$result['gameID']] = $result['pickID'];
if (!empty($games[$result['gameID']]['winnerID']) && $result['pickID'] == $games[$result['gameID']]['winnerID']) {
//player has picked the winning team
$playerTotals[$result['userID']] += 1;
} else {
if ( $playerTotals[$result['userID']] += 0);
}
$i++;
}
echo '<pre>';
print_r($playerPicks);
echo '<pre>';
Output
Array A
(
[2] => Array
(
[433] => GB
)
[924] => Array
(
[435] => PIT
)
[934] => Array
(
[434] => OAK
)
)
Array B
(
[2] => Array
(
[433] => GB
[433] => GB
)
[924] => Array
(
[435] => PIT
[435] => PIT
)
[934] => Array
(
[434] => OAK
[434] => OAK
)
)