Jump to content

help with creating latest score table


kenny22

Recommended Posts

I'm in the process of creating a webage that shows latest scores and an updated league table for soccer/football matches like the bbc sports website does.

 

I have the database set up with a form to update and display latest score all work well apart from if i update a score like the following

 

teamA  1  teamB  0  it updates table to give  teamA 3 points based on the current score however if teamA score again

teamA 2 teamB 0 it updates table again  but gives teamA another 3 points which is not correct so i need a way to stop it happening.

 

thought about it for a while and only thing i can come up with is some maths to compare the values of score for each team and add/remove points as dependent on current score.

 

 

Anyone got something similar to this

Link to comment
Share on other sites

Wait...in what country do soccer games score in 3-point intervals?

 

Why are you claiming your queries will update the wrong way...or something.

 

Show the queries you're running.

 

Your WHERE clause should be identifying these games based on a unique identifier (either an auto-increment ID in the database or by team/date), not by score.

 

-Dan

Link to comment
Share on other sites

here in uk, 3pts for win, 1 for a draw

 

what i have come up

 

if ($score1 > $score2) {

$homepoints = '3'; $awaypoints = '0'; $homewin = 'W'; $awaywin = 'L';

}

 

if ($score1 < $score2) {

$homepoints = '0'; $awaypoints = '3'; $homewin = 'L'; $awaywin = 'W';

}

if ($score1 == $score2) {

$homepoints = '1'; $awaypoints = '1'; $homewin = 'D'; $awaywin = 'D';

}

 

going to do some more work on form page so that it looks at the value of  $homewin, $awaywin and allocates points from there, was hoping someone had already solved this problem before

 

thanks for reply

 

kenny

 

 

 

 

 

Link to comment
Share on other sites

Oh, so in addition to "keeping score" for the game itself, you're also "scoring" the teams in league play.  Those should be kept in a separate table (or calculated on the fly). 

 

Don't give the team the 3 points until after the game is finished with.

 

-Dan

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.