Simple scoring systemsimple scoring system
Page 1 of 1
7 Replies - 6298 Views - Last Post: 04 September 2009 - 05:21 AM
#1
Simple scoring system
Posted 15 April 2008 - 03:37 AM
Say the club is having a tour consists of 7 tournaments. I want to display the data with the player name, tee time, with the results from all 7 tournaments then have a running score. How do you do that?
Replies To: Simple scoring system
#2
Re: Simple scoring system
Posted 15 April 2008 - 05:47 PM
For example, if you have table "PingPongBallClassic" that contains the scores for the Ping Pong Ball Tournament, you might want to try this (this also assumes that the Golfer's name is in column "Name", Tee Time is "TeaTime" and score is "score":
// Connect to mysql database up here
$query = mysql_query("select * from PingPongBallClassic order by score") or die(mysql_error());
while($array = mysql_fetch_array($query)) {
echo "{$array['name']} : {$array['score']} (Teed at {$array['TeaTime']}) ";
}
?>
which would output in:
John Doe: -2 (Teed at 12:13)
format.
To display the top scores, try changing the while loop to a for loops.
And of course you can format with HTML / CSS
#3
Re: Simple scoring system
Posted 15 April 2008 - 10:58 PM
As you can probably tell I'm a designer and don't to familiar with code. So if I setup a table like such:
name T1 T2 T3 T4 T5 T6 T7 Results
As I entered in the results from the input form they will be averaged out and displayed from the lowest average to the highest in the Results column. Thanks again for any advice.
#4
Re: Simple scoring system
Posted 16 April 2008 - 05:42 AM
spearfish, on 15 Apr, 2008 - 05:47 PM, said:
I don't know if I would recommend this.
I would recommend having a look up table with all the tournaments and associated IDs, and then have ONE table link back to the IDs as opposed to 7 tables. When you want to show data for ONE tournament, you simply pass it that tourny ID. This way; you can EASILY add/remove tournaments without having to do any code changes, it keeps your database structure simpler. Also, in the code you can use the exact same query for all 7 tournaments by simply passing it the ID.
There are multiple ways to solve the problem; its up to you which you find to be the easiest
#5
Re: Simple scoring system
Posted 16 April 2008 - 03:41 PM
Thanks for your input. I already the database setup the way you described. My big problem is the code on averaging the scores.
Like I made mention before I'm a designer that uses Dreamweaver an I rely on Dreamweaver to handle the coding part for my. I know that in itself is not that good. But Dreamweaver is easy to use for a Novice like myself.
When it comes to writing code for math calculations, I'm lost. I just need a simple calculation for a table like such:
name T1 T2 T3 T4 T5 T6 T7 Results
Where when I enter the score for a player for each tournament it will display an average for the player in the results column.
#6
Re: Simple scoring system
Posted 22 April 2008 - 08:48 AM
1) the persons name
2) the time they teed off
3) the score of the 7 tornaments
4) the average of those tornaments
I will show you how i would achieve this, i'm not the most experienced php coder so it may be weak and might need tweaking but as far as i can see it will work.
for this to work you should set the default of the tornament values to N/A and then update them as the tournament is played this will make the result average the played tornaments and not the average the ones with a score of 0 that haven't been played yet.
I also set the rounding of the average to 2 decimal places i am not a golf fan so i dont know what it should be set at.
<table>
<tr>
<td>Name</td><td>Tee time</td><td>T1</td><td>T2</td><td>T3</td><td>T4</td><td>T5</td><td>T6</td>
<td>T7</td><td> Results</td></tr>
<?php
$query = mysql_query("SELECT * FROM tournament") or die(mysql_error());
while($fetch = mysql_fetch_assoc($query)) {
$divide = "0";
$score = "0";
$name = $fetch->name;
$tee = $fetch->tee;
$t1 = $fetch->t1;
$t2 = $fetch->t2;
$t3 = $fetch->t3;
$t4 = $fetch->t4;
$t5 = $fetch->t5;
$t6 = $fetch->t6;
$t7 = $fetch->t7;
?>
<tr><td><?echo "$fetch->name";?></td><td><?echo "$fetch->tee";?></td><td><?echo "$t1";?></td><td><?echo "$t2";?></td><td><?echo "$t3";?></td><td><?echo "$t4";?></td><td><?echo "$t5";?></td><td><?echo "$t6";?></td><td><?echo "$t7";?></td><td>
<?
if($t1!='N/A') {
$score = $score+$t1;
$divide++;
}
if($t2!='N/A') {
$score = $score+$t2;
$divide++;
}
if($t3!='N/A') {
$score = $score+$t3;
$divide++;
}
if($t4!='N/A') {
$score = $score+$t4;
$divide++;
}
if($t5!='N/A') {
$score = $score+$t5;
$divide++;
}
if($t6!='N/A') {
$score = $score+$t6;
$divide++;
}
if($t7!='N/A') {
$score = $score+$t7;
$divide++;
}
$division = $score/$divide;
$result = round($division, 2);
echo "$result";
echo "</td></tr>";
}
if you notice a problem with this script let me know
KiNgY
This post has been edited by KiNgY: 22 April 2008 - 08:51 AM
#7
Re: Simple scoring system
Posted 03 September 2009 - 02:34 PM
BDX, on 15 Apr, 2008 - 02:37 AM, said:
Say the club is having a tour consists of 7 tournaments. I want to display the data with the player name, tee time, with the results from all 7 tournaments then have a running score. How do you do that?
Hi BDX,
I see you hav egone through the same process I am abou tto endevour.
I am trying to find out how far you got with the golf scoring program?
Regards
Rob
#8
Re: Simple scoring system
Posted 04 September 2009 - 05:21 AM
Below is a screencap of what I think you want, (obviously style aside), is this what you want? If it is, I'll tell you how to achieve it.

Something like the above. If it is, we can advance from there. If it isn't call me an idiot
Edit: The order isn't in the screencap either, since that was just manually written out, but the final version will be able to show them in any order needed (but defaulted to lowest average)
Edit Edit: You don;t need the total column either. Av. is the average, and can be renamed to "results"
This post has been edited by Bladescope: 04 September 2009 - 05:24 AM
|
|

New Topic/Question
Reply




MultiQuote





|