Help Needed With a Script for Calculations [SOLVED]
Posted: Tue Apr 24, 2007 2:25 am
I am attempting to create a php script for a golf website, the problem is that I am new to PHP and I have become stuck as I can't see were the error lies in the below code. The script calculates based on the variables but I thought I would have a number returned at the end of the script but nothing is displayed can anyone see any errors?
I have automatically set the variables to 4 so I can see if the script is calucalting correctly, once the script is working the values will be determined from an entry in a form.
if you want to know what the script is supposed to add up like let me know an I will do my best to explain or look up stableford points in golf.
Thank you in advance.
Tom
*** PLEASE USE THE PHP TAG WHEN POSTING CODE ***
I have automatically set the variables to 4 so I can see if the script is calucalting correctly, once the script is working the values will be determined from an entry in a form.
if you want to know what the script is supposed to add up like let me know an I will do my best to explain or look up stableford points in golf.
Thank you in advance.
Tom
*** PLEASE USE THE PHP TAG WHEN POSTING CODE ***
Code: Select all
<?php
$count = 0;
$score = 4;
$si = 4;
$handicap = 4;
$par = 4;
if ($handicap >= 0) {
if ($score > 0) {
$sp = 0;
if ($handicap = 0) {
$sp = $score;
} else if ($handicap <= 18){
For ($count = 1; $count = $handicap; $count++){
if ($si = $count) {
$sp = $score - 1;
} else {
$sp = $score;
}
}
} else if ($handicap >= 19 && $handicap <= 36){
$handicap = $handicap - 18;
For ($count = 1; $count = $handicap; $count++){
if ($si = $count) {
$sp = $score - 2;
} else {
$sp = $score -1;
}
}
}
if ($sp - 1 = $par){
$stablefordpoints = 1;
echo "$stablefordpoints";
} else if ($sp - 2 = $par){
$stablefordpoints = 2;
echo "$stablefordpoints";
} else if ($sp - 3 = $par){
$stablefordpoints = 3;
echo "$stablefordpoints";
} else if ($sp - 4 = $par){
$stablefordpoints = 4;
echo "$stablefordpoints";
} else if ($sp - 5 = $par){
$stablefordpoints = 5;
echo "$stablefordpoints";
}
}
}
?>