User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion
Register FAQ Members List Calendar Arcade Today's Posts

Reply
Thread Tools Display Modes
Unread 27 Sep 2003, 22:34   #1
Ragnarak
Registered User
 
Ragnarak's Avatar
 
Join Date: Oct 2000
Posts: 4,944
Ragnarak is a splendid one to beholdRagnarak is a splendid one to beholdRagnarak is a splendid one to beholdRagnarak is a splendid one to beholdRagnarak is a splendid one to beholdRagnarak is a splendid one to beholdRagnarak is a splendid one to behold
PHP Help :(

Ok, what i'm basically trying to do is make a premiership league table that updates when you put the results in.

I've got the inputting results into the database bit done fine, and i can display the results as HTML but what i need to do is say if scorea > scoreb give teama 3 points, etc and not sure how i go about doing this...

Any suggestions or advice?
__________________
I find it kind of funny
I find it kind of sad
The dreams in which i'm dying
Are the best i've ever had
Ragnarak is offline   Reply With Quote
Unread 27 Sep 2003, 22:59   #2
Dave
Infallible
 
Join Date: Feb 2001
Location: Milton Keynes, UK
Posts: 604
Dave is an unknown quantity at this point
Assuming that your using MySQL, and that I understand you...

Code:
$teamascore = 2;
$teambscore = 4;

if($teamascore > $teambscore) {
    mysql_query("UPDATE league SET points=points+3 WHERE team='$teamaid'");
} elseif($teambscore > $teamascore) {
    mysql_query("UPDATE league SET points=points+3 WHERE team='$teambid'");
} else { //Draw
   mysql_query("UPDATE league SET points=points+1 WHERE teamid='$teamaid' OR teamid='$teambid'");
}
Something along those lines.

(Yes its bad code, but who cares)
Dave is offline   Reply With Quote
Unread 27 Sep 2003, 23:01   #3
Ragnarak
Registered User
 
Ragnarak's Avatar
 
Join Date: Oct 2000
Posts: 4,944
Ragnarak is a splendid one to beholdRagnarak is a splendid one to beholdRagnarak is a splendid one to beholdRagnarak is a splendid one to beholdRagnarak is a splendid one to beholdRagnarak is a splendid one to beholdRagnarak is a splendid one to behold
cheers, that looks like it'll be useful
__________________
I find it kind of funny
I find it kind of sad
The dreams in which i'm dying
Are the best i've ever had
Ragnarak is offline   Reply With Quote
Unread 28 Sep 2003, 11:09   #4
mbushell
Registered User
 
mbushell's Avatar
 
Join Date: Jul 2000
Location: :noitacoL
Posts: 1,200
mbushell spreads love and joy to the forum in the same way Jesus wouldmbushell spreads love and joy to the forum in the same way Jesus wouldmbushell spreads love and joy to the forum in the same way Jesus wouldmbushell spreads love and joy to the forum in the same way Jesus wouldmbushell spreads love and joy to the forum in the same way Jesus wouldmbushell spreads love and joy to the forum in the same way Jesus wouldmbushell spreads love and joy to the forum in the same way Jesus wouldmbushell spreads love and joy to the forum in the same way Jesus wouldmbushell spreads love and joy to the forum in the same way Jesus wouldmbushell spreads love and joy to the forum in the same way Jesus wouldmbushell spreads love and joy to the forum in the same way Jesus would
Code:
$a['points'] = 0;
$a['score'] = 2;  
$b['points'] = 0;   
$b['score'] = 4;  

if ($a['score'] > $b['score']) {
    // team `a` wins
    $a['points'] += 3;
    // mysql crap
} elseif ($a['score'] < $b['score']) {
    // team `b` wins
    $b['points'] += 3;
    // mysql crap
} else {
    // it's a draw baby yeh
    $a['points']++;
    $b['points']++;
    // mysql crap
}
mbushell is offline   Reply With Quote
Unread 28 Sep 2003, 11:15   #5
Structural Integrity
Rawr rawr
 
Structural Integrity's Avatar
 
Join Date: Dec 2000
Location: Upside down
Posts: 5,300
Structural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriendStructural Integrity needs a job and a girlfriend
I'd go for something more error-secure.
If you now make a typo in the scores you can't turn it back.

I'd store each game outcome and then for a request count the won games and draws, and calculate the scores accordingly.
Structural Integrity is offline   Reply With Quote
Reply



Forum Jump


All times are GMT +1. The time now is 13:03.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018