Simple scoring system

simple scoring system

Page 1 of 1

7 Replies - 7548 Views - Last Post: 04 September 2009 - 05:21 AM Rate Topic: -----

#1 BDX  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-April 08

Simple scoring system

Post icon  Posted 15 April 2008 - 03:37 AM

I'm building a website for a client for a golf club. I use Dreamweaver to build my sites and I know how to setup a database using MySQL. I also know how to integrate my data into my site. Here is my question.

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?
Is This A Good Question/Topic? 0
  • +

Replies To: Simple scoring system

#2 spearfish  Icon User is offline

  • Monkey in Training
  • member icon

Reputation: 10
  • View blog
  • Posts: 746
  • Joined: 10-March 08

Re: Simple scoring system

Posted 15 April 2008 - 05:47 PM

I would create seven tables in my database using MySQL. Each table would represent a tournament. Then to display the data I'd use either a "for" or "while" loop combined with mysql_fetch_array.

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
Was This Post Helpful? 0
  • +
  • -

#3 BDX  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-April 08

Re: Simple scoring system

Posted 15 April 2008 - 10:58 PM

Thanks for your input spearfish I really appreciate your time and expertise. I talked to my client again and he wants to list the tea times separately from the scores because the tea times will change from tournament to tournament. Will this code display the overall average of the 7 tournament as they are entered?

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.
Was This Post Helpful? 0
  • +
  • -

#4 JasonMcAuley  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 144
  • Joined: 10-April 08

Re: Simple scoring system

Posted 16 April 2008 - 05:42 AM

View Postspearfish, on 15 Apr, 2008 - 05:47 PM, said:

I would create seven tables in my database using MySQL. Each table would represent a tournament.


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 :)
Was This Post Helpful? 0
  • +
  • -

#5 BDX  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 15-April 08

Re: Simple scoring system

Posted 16 April 2008 - 03:41 PM

Mr. McAuley,
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.
Was This Post Helpful? 0
  • +
  • -

#6 KiNgY  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 07-March 08

Re: Simple scoring system

Posted 22 April 2008 - 08:48 AM

Okay if my understanding of what you are asking for is correct you want ..

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 :D

KiNgY

This post has been edited by KiNgY: 22 April 2008 - 08:51 AM

Was This Post Helpful? 0
  • +
  • -

#7 Oryan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-September 09

Re: Simple scoring system

Posted 03 September 2009 - 02:34 PM

View PostBDX, on 15 Apr, 2008 - 02:37 AM, said:

I'm building a website for a client for a golf club. I use Dreamweaver to build my sites and I know how to setup a database using MySQL. I also know how to integrate my data into my site. Here is my question.

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
Was This Post Helpful? 0
  • +
  • -

#8 Bladescope  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 71
  • Joined: 01-September 09

Re: Simple scoring system

Posted 04 September 2009 - 05:21 AM

BDX, I think I understand what you mean now after reading the posts (although I may also be terribly wrong).

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.

Posted Image

Something like the above. If it is, we can advance from there. If it isn't call me an idiot :P.

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" :P

This post has been edited by Bladescope: 04 September 2009 - 05:24 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1