/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Help

I am trying to do some count on a database and put them in order. Here is the code that i am useing

[code=php]
<?php echo $row_getSoccerScores[‘AgeGroup’]; ?>
</label>
<input name=”Year” type=”hidden” id=”Year” value=”<?php echo $row_getSoccerScores[‘Year’]; ?>” />
<input name=”Season” type=”hidden” id=”Season” value=”<?php echo $row_getSoccerScores[‘Season’]; ?>” />
</p>
<table width=”600″ border=”1″ align=”center”>
<tr>
<td><div align=”center”><strong>Game</strong></div></td>
<td nowrap=”nowrap”><div align=”center”><strong>Team</strong></div></td>
<td><div align=”center”><strong>Score</strong></div></td>
<td><div align=”center”><strong>Points</strong></div></td>
</tr>
<?php do { ?>
<tr>
<td><div align=”center”><?php echo $row_getSoccerScores[‘Week’]; ?></div></td>
<td nowrap=”nowrap”><p align=”center”><?php echo $row_getSoccerScores[‘HomeTeam’]; ?></p>
<p align=”center”>&nbsp;<?php echo $row_getSoccerScores[‘AwayTeam’]; ?></p></td>
<td><p align=”center”><?php echo $row_getSoccerScores[‘HomePointsScore’]; ?> <?php echo $row_getSoccerScores[‘HomwWinorLoss’]; ?></p>
<p align=”center”>&nbsp;<?php echo $row_getSoccerScores[‘AwayPointScore’]; ?> <?php echo $row_getSoccerScores[‘AwayWinorLoss’]; ?></p></td>
<td><p align=”center”><?php echo $row_getSoccerScores[‘HomePointsEarned’]; ?></p>
<p align=”center”><?php echo $row_getSoccerScores[‘AwayPointsEarned’]; ?></p></td>
</tr>
<?php $myhash[$row_getSoccerScores[‘HomeTeam’]] += $row_getSoccerScores[‘HomePointsEarned’] ;?>
<?php $myhash[$row_getSoccerScores[‘AwayTeam’]] += $row_getSoccerScores[‘AwayPointsEarned’] ;?>
<?php $myhash1[$row_getSoccerScores[‘AwayTeam’]] += $row_getSoccerScores[‘AwayPointsScore’] ;?>
<?php $myhash1[$row_getSoccerScores[‘HomeTeam’]] += $row_getSoccerScores[‘HomePointsScore’] ;?>
<?php $myhash2[$row_getSoccerScores[‘AwayTeam’]] += $row_getSoccerScores[‘HomePointsScore’] ;?>
<?php $myhash2[$row_getSoccerScores[‘HomeTeam’]] += $row_getSoccerScores[‘AwayPointsScore’] ;?>

<?php } while ($row_getSoccerScores = mysql_fetch_assoc($getSoccerScores)); ?>
</table>
<p>
</p>
<h1>Ranking</h1>
<table width=”600″ border=”1″>
<tr>
<td><div align=”center”>Rank</div></td>
<td><div align=”center”>Team Name</div></td>
<td><div align=”center”>Total Points Earned</div></td>
<td><div align=”center”>Total Scored Made</div></td>
<td><div align=”center”>Total Scored Allowed</div></td>
</tr>
<?php
$count = 0;
arsort ($myhash);
foreach ($myhash as $key => $value)
{ $count++; ?>
<tr>
<td><div align=”center”><?php echo $count; ?></div></td>
<td><div align=”center”><?php echo $key; ?></div></td>
<td><div align=”center”><?php echo $value; ?></div></td>
<td><div align=”center”><?php echo $myhash1[$key]; ?></div></td>
<td><div align=”center”><?php echo $myhash2[$key]; ?></div></td>
</tr>
<?php } ?>
</table>
[/code]

Put for some reason the $myhash2 is not counting corretly. Is there another way of doing this

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @rwtrwt2003 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...