Somewhat a project here

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Somewhat a project here

Post 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
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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)
Last edited by John Cartwright on Wed Feb 04, 2004 3:44 pm, edited 2 times in total.
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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?
User avatar
johnperkins21
Forum Contributor
Posts: 140
Joined: Mon Oct 27, 2003 4:57 pm

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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..
Post Reply