Forums

This topic is locked

Football (Soccer) Table

Posted 09 Jan 2003 12:52:13
1
has voted
09 Jan 2003 12:52:13 Perry Gascoine posted:
I have been asked to build a football (soccer) site.

When the user enters the scores I need it to convert it to a placing table

Ie

Chelsea 3 Man Utd 0 <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Would show as follows:

Chelsea Played 1 Won 1 Lost 0 Draw 0 Goals For 3 Goals Against 0
Man Utd Played 1 Won 0 Lost 1 Draw 0 Goals For 0 Goals Against 3

Anyone know how to do this or better still is there an extension out there (or is someone writing one?)

Cheers

Perry

....It's only easy if you know the answer

Replies

Replied 09 Jan 2003 13:42:11
09 Jan 2003 13:42:11 Owen Eastwick replied:
Hi Perry,

See HowToMx.com <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 09 Jan 2003 14:29:42
09 Jan 2003 14:29:42 Perry Gascoine replied:
Knowledge is not always the key.

A win is worth 3 points where a draw is worth 1 point. A loss is worth 0 points.

My SQL skills could be written in large letters on a daisy leaf.

What I need is for the user to enter the score.

The SQL would know that if team 'A' score is higher than team 'B' then team A wins (and gets 3 points).

If team 'A' score is the same than team 'B' score than both get 1 point

Etc, etc.

Any tips or help would be appreciated.....

Regards

Perry

....It's only easy if you know the answer
Replied 13 Jan 2003 11:36:23
13 Jan 2003 11:36:23 Julio Taylor replied:
Perry,

I know exactly what you need. I have some ideas... you'll need to set up a form with obviously 4 fields:

a. Team_1
b. Team_1_Score
c. Team_2
d. Team_2_Score

When the user clicks on the button, you send the information (via GET_VAR) to another page, say 'calculate.php'. This page will do the following, in this order:

1. Assign each GET_VAR value to a php variable, (e.g. VarTeam1, VarTeam1Score, etc), plus 2 new variables which will carry the number of points that each team take home (you can call it ScoreVar1 and ScoreVar2 if you like).

2. Run a simple conditional statement to find out which is higher to decide which team gets points, like so (in loose code):
<pre id=code><font face=courier size=2 id=code>
if VarTeam1Score &gt; VarTeam2Score then (add 3 points to team 1's variable)
elseif
VarTeam1Score &lt; VarTeam2Score then (add 3 points to team_2's ScoreVar2)
else if
VarTeam1Score = VarTeam2Score (add 1 to both ScoreVar1 and ScoreVar2)
</font id=code></pre id=code>

you can then assign the values of ScoreVar1 and ScoreVar2 to hidden fields in a form in the same page, finally updating the data tables accordingly by the values set in the variables.

You can also create other vars and condtional statements to add W, D and L figures to each team. To do that, simply create more variables and assign values to them inside the conditional statement.

Another way to do it could be to run another conditional statement (after the point one) to decide whether it's a win, loss or draw (depending on whether it's 1, 3 or 0, the result is always unique.

In my personal experience it is always better to keep the tables simple, and only have 5 fields per team (W, D, L, GF and GA). The rest of the stuff is calculated in the php pages, given the fact that all wins are 3 and all draws are 0, total point and league positions are very easy to calculate.

Keep posting here, i can probably help you some more on this..



------------------------
Julio

PHP | MySQL | UD4

ICQ: 19735247

Edited by - poolio on 13 Jan 2003 11:36:51

Reply to this topic