Scoreboard

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iceman83
Forum Newbie
Posts: 9
Joined: Sat Sep 06, 2008 1:34 pm

Scoreboard

Post by iceman83 »

Greetings Mates,
I have a scoreboard script that we use for a game I play. It works and all but i wanna remake it so its alittle easer to work with or something like that.. and old friend made it before things went wrong and he left and he was the main programmer and well I wanna try making this one alittle bit better then what it is now..

Could someone help me on figuring out how to make it alittle bit better? I been messing around with php for a while around 2 or 3 years but not fully good with the functions on this script.

here is the script..

Code: Select all

    <table width="565" border="1" bordercolor="FFFFFF">
  <tr>
    <td colspan="10" class="txt"><center>Overall Score</center></td>
  </tr>
  <tr>
    <td class="txt">Month</td>
    <td class="txt">Games</td>
    <td class="txt">Human Kills</td>
    <td class="txt">Wins</td>
    <td class="txt">Losses</td>
    <td class="txt">Draws</td>
    <td class="txt">DNF's</td>
    <td class="txt">Bonus</td>
    <td class="txt">Duty</td>
    <td class="txt">Total</td>
  </tr>
<?php 
            $date_it = array();
        $query_report_dates = "SELECT date FROM reports WHERE user_name='$user_name'";
        $result_report_dates = mysql_query($query_report_dates) or die("QUERY REPORT DATES FAILED: ".mysql_error());
        while ($line = mysql_fetch_array($result_report_dates)) {
            $date = $line['date'];
            $dater = explode("-", $date);
            $yr_mon = $dater[0]."-".$dater[1];
            if (!in_array($yr_mon, $date_it)) {
                array_push($date_it, $yr_mon);
            }
        }
        $date_it_count = count($date_it);
        for ($i=0;$i<$date_it_count;$i++) {
            $month_games = 0;
            $month_kills = 0;
            $month_wins = 0;
            $month_lost = 0;
            $month_draws = 0;
            $month_dnf = 0;
            $month_bonus = 0;
            $month_duty = 0;
            $month_total = 0;
            $dater_mon = explode("-", $date_it[$i]);
            $query_reports = "SELECT date,kills,wins,lost,draws,dnf,bonus,duty,total FROM reports WHERE user_name = '$user_name' AND MONTH(date)=$dater_mon[1] AND YEAR(date)=$dater_mon[0]";
            $result_reports = mysql_query($query_reports) or die('Query failed: ' . mysql_error());
            while ($line = mysql_fetch_array($result_reports)) {
                
                $kills = $line['kills'];
                $wins = $line['wins'];
                $lost = $line['lost'];
                $draws = $line['draws'];
                $dnf = $line['dnf'];
                $bonus = $line['bonus'];
                $duty = $line['duty'];
                $total = $line['total'];
                
                $total_games++;
                $total_kills += $kills;
                $total_wins += $wins;
                $total_lost += $lost;
                $total_draws += $draws;
                $total_dnf += $dnf;
                $total_bonus += $bonus;
                $total_duty += $duty;
                $total = $duty + $total + $bonus;
                $total_total += $total;
                
                $month_games++;
                $month_kills += $kills;
                $month_wins += $wins;
                $month_lost += $lost;
                $month_draws += $draws;
                $month_dnf += $dnf;
                $month_bonus += $bonus;
                $month_duty += $duty;
                $month_total += $total;
                
            }
            ?>
            <tr>
    <td class="txt"><?php echo $date_it[$i]; ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($month_games); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($month_kills); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($month_wins); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($month_lost); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($month_draws); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($month_dnf); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($month_bonus); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($month_duty); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($month_total); ?>&nbsp;</td>
  </tr>
  <?php } ?>
    <tr>
    <td class="txt">Total</td>
    <td class="txt"><?php echo number_format($total_games); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($total_kills); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($total_wins); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($total_lost); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($total_draws); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($total_dnf); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($total_bonus); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($total_duty); ?>&nbsp;</td>
    <td class="txt"><?php echo number_format($total_total); ?>&nbsp;</td>
  </tr>
</table>
There is more too it but its not needed its for a different part of the page..


Thank you mates.
Iceman83
Post Reply