Calculating wins & losses in Football Pool
Moderator: General Moderators
Calculating wins & losses in Football Pool
Hi,
I'm creating a site that will take football picks from users and then calculate their records automatically. What would be the best way calculate the records?
Thanks...
I'm creating a site that will take football picks from users and then calculate their records automatically. What would be the best way calculate the records?
Thanks...
- ReverendDexter
- Forum Contributor
- Posts: 193
- Joined: Tue May 29, 2007 1:26 pm
- Location: Chico, CA
lol. Well I need to get the wins and losses so I'm thinking something like this:
And then this would be updated to the database for that user. However I'm having some difficulty with it. Losses always comes out as 15 when it should be 0. Also this process needs to be repeated about 16 times before being output as the final record and if a game is left blank it needs to not effect this.
Code: Select all
if ($winner==$chosen_team) {
$wins=$wins+1;
} else {
$losses=$losses+1;
}I resent that!ReverendDexter wrote:What exactly do you mean by calculate their records? Do you mean right picks vs. wrong picks? You'll have to forgive us nerds and our ignorance of sports-like things
For skipping blank ones.. I'd assume the winner is not set if it's blank.. set if its not blank.. so:
Code: Select all
if (isset($winner))
{
//code here
}Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Hmm... I think you're right.Jcart wrote:This sounds like it should be calculated by the database.
How are you storing the users picks as well as the team outcomes?
I'm using three seperate databases - one for determining the games (what weeks they're on and what season as well as the home, away team and final winner), another for the users info and their records, and a third for picks.
btw thanks scottay your advice seems to have worked.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
I had to respond since I just wrote a full football pools script with the tie-breaker score included.
As for the wins/losses, I have one table that contains the totals for the full season. This table is updated at the end of each week with a scipt we fun from our admin area.
For each week, the script just builds the wins/losses on the fly.. heres a small example. This simply checks team 1 greater than team 16 and awards a win.
PM me if you would like to have a look at the site.
As for the wins/losses, I have one table that contains the totals for the full season. This table is updated at the end of each week with a scipt we fun from our admin area.
For each week, the script just builds the wins/losses on the fly.. heres a small example. This simply checks team 1 greater than team 16 and awards a win.
Code: Select all
if( $user_picks[$i] == 1 ){
if ( $results_info[($i - 1)] > $results_info[($i + 15)] ){
$win = $win + 1;
echo "<FONT COLOR='#004000'><B>";
} else { $loss = $loss + 1; }
}