Page 1 of 1

Somewhat a project here

Posted: Wed Feb 04, 2004 3:31 pm
by John Cartwright
Okay I'm building a gaming website and I'm planning on making a little script that has the records. The admin enters the records with a form that looks like this

Opponent:
Map:
Date:
Win/loss/tie:
Scrim/Cal:

I know how to enter this all into a database and everything blah blah but my problem is this.

In my main page http://www.jcartonline.com/xe/ You will see A little Records part that looks like this

Cal - 100-0-0 - .999 - info
Scrim - 100-0-0 - .999 - info

What I can't really figure out is how I'm going to calculate the totals wins and losses for each different one. I'm thinking maybe I should have 2 different tables to seperate them... another problem is how am I going to get the decimal. For those of you who are unware .500 is 1-1 ratio and 1.0 is 1-0 ... so 2-1 would be like .750

Posted: Wed Feb 04, 2004 3:38 pm
by Unipus
I don't understand your question at all. Are you asking about the table structure? What is it you actually need to accomplish?

Posted: Wed Feb 04, 2004 3:41 pm
by John Cartwright
My question is this:

How do I count the number is wins/losses/ties.
Other question how do I get the ratio of wins to losses in this form .999

I know how the structure is going to look like

1 table for cal
1 table for scrim

each table is going to have these values

date - opponent - outcome (win/loss/tie) - map - competition (cal/scrim)

Posted: Wed Feb 04, 2004 3:42 pm
by Unipus
1) you should probably have a separate table for team data and for matches. add up the total results in matches to get your win/loss record. hard to say, because I don't know what else your db might need to track, how many teams there are, etc.

2) division.

Posted: Wed Feb 04, 2004 3:43 pm
by John Cartwright
I updated my last post... i hoped that I would of finished in it time b4 you wrote your response :(

Btw this is only for 1 team... 2 divisions... cal and scrim

Posted: Wed Feb 04, 2004 3:49 pm
by John Cartwright
i was thinking...... inside a loop just have this

if ($row['outcome'] == win) {

$calwins = $calwins + 1;

}elseif ($row['outcome'] == loss) {

$calloss = $calloss +1;

}



would something like that work?

Posted: Wed Feb 04, 2004 4:16 pm
by johnperkins21
I'm a noob so forgive my response, but wouldn't you just add a column in your db that would update the wins and losses total as they are inserted??

Like

Scrim = win
Cal = loss
Add scrim_wins +1 to database
Add cal_loss +1 to database

Scrim = loss
Cal = win
Add scrim_loss +1 to database
Add cal_loss +1 to database

etc, etc.

If I'm way off, again, I apologize, but this is how I would go about it. I would store as much of the info in the db as possible.

Posted: Wed Feb 04, 2004 4:37 pm
by John Cartwright
No actually that makes perfect sense.... it's always good to voice your opinion even if you think your wrong.. cause you know what, peoples opinions give you different perspective on things..