Siggles Posted January 23, 2008 Share Posted January 23, 2008 Hi there, I have a football prediction website I am trying to create The rules are (usually calculated in Excel)... Scoring Rules 1. Each correctly predicted exact score will win a total of 25 points. 2. Each correctly predicted result ( either win, lose, or draw) will win 10 points. NOTE: exact scorers do NOT receive additional 10 points. 3. A single point (IE 1 point) will be deducted for each goal scored over or under the total goals predicted. Therefore, accuracy of total number of goals predicted will affect the scores. I am trying to do the equivalent in PHP and so far I have got... function add_parameters($one, $two, $three, $four) { global $sum; if ($one==$two && $three==$four) //correctly predicted score - Rule 1 $sum+=25; elseif ($one==$three && $two==$four) //both draw so 10 points - Rule 2 $sum+=10; elseif ($one>$three && $two>$four) //both win so 10 points - Rule 2 $sum+=10; elseif ($one<$three && $two<$four) //both lose so 10 points - Rule 2 $sum+=10; } Does anyone know how I might do rule/score 3 where the difference between numbers is important? And can anyone see any probs with what I have so far? Some examples below of how scores should be... NOTE: A result of Millwall 4-1 west h*m is used in all the examples below: Example #1: if a 0-0 result was predicted, then 5 points will be deducted. Example #2: if any 1-0 result was predicted, then 4 points will be deducted. Example #3: if any 2-0 result or 1-1 draw was predicted, then 3 points will be deducted. Example #4 if any 3-0, 2-1 or 4-3 result was predicted then 2 points will be deducted. Example #5 if a 3-1, 5-1, 4-0 or 6-0 result or a 2-2 or 3-3 draw was predicted then 1 point will be deducted. Example #6 if a 3-2 or 5-0 result was predicted (or God forbid a 1-4 win by west h*m) then NO points will be deducted. Link to comment https://forums.phpfreaks.com/topic/87360-maths-formulas-for-submitting-scores-to-dbase/ Share on other sites More sharing options...
Siggles Posted January 23, 2008 Author Share Posted January 23, 2008 The function might make more sense with these variables... function add_parameters($score_home, $prediction_home, $score_away, $prediction_away) { global $sum; if ($score_home==$prediction_home && $score_away==$prediction_away) //correctly predicted score - Rule 1 $sum+=25; elseif ($score_home==$score_away && $prediction_home==$prediction_away) //both draw so 10 points - Rule 2 $sum+=10; elseif ($score_home>$score_away && $prediction_home > $prediction_away) //both win so 10 points - Rule 2 $sum+=10; elseif ($score_home<$three && $prediction_home < $prediction_away) //both lose so 10 points - Rule 2 $sum+=10; } Link to comment https://forums.phpfreaks.com/topic/87360-maths-formulas-for-submitting-scores-to-dbase/#findComment-446836 Share on other sites More sharing options...
Barand Posted January 23, 2008 Share Posted January 23, 2008 try <?php function add_parameters($score_home, $prediction_home, $score_away, $prediction_away) { global $sum; if ($score_home==$prediction_home && $score_away==$prediction_away) //correctly predicted score - Rule 1 $sum+=25; elseif ($score_home==$score_away && $prediction_home==$prediction_away) //both draw so 10 points - Rule 2 $sum+=10; elseif ($score_home>$score_away && $prediction_home > $prediction_away) //both win so 10 points - Rule 2 $sum+=10; elseif ($score_home<$three && $prediction_home < $prediction_away) //both lose so 10 points - Rule 2 $sum+=10; // add this $sum -= abs (($prediction_home + $prediction_away) - ($score_home + $score_away)); } ?> Link to comment https://forums.phpfreaks.com/topic/87360-maths-formulas-for-submitting-scores-to-dbase/#findComment-446861 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.