Hello everyone,
I am really stuck! Right now I have a field that would look something like this:
$StandingGF/$StandingGA
"StandingGF" and "StandingGA" are fields in the database.
$myCalculation="$StandingGF /$StandingGA";
I found a way to get those values out of the equation; I used:
list($restOfString, $theFieldTemp) = split ("$", $myCalculation, 2);
list($theField1, $restOfString) = split (" ", $theFieldTemp, 2);
list($restOfString, $theFieldTemp1) = split ("$", $restOfString, 2);
list($theField2, $restOfString) = split (" ", $theFieldTemp1, 2);
So now $theField1=StandingGF
AND $theField2=StandingGA
SO I used these two fields now to query the database:
$sql="SELECT $theField1, $theField2
FROM MyTable
WHERE .....";
I put the results from the query into an array (statArray). Now how do I take the first value, and put it in the spot of $StandingGF in the equation? And how do I get the second value in the place of $StandingGA in the equation??
Now I have those values, but how do I assign them back to the original field names?
This is what I tried:
for($i=0;$i<sizeof($statArray);$i++){
$$theField1=$statArray[$i][0];
$$theField2=$statArray[$i][1];
}
$string = str_replace(" ", "", $myCalculation);
$answer=$string;
print"answer to Calculation:$answer";
And all it does is print:
"answser to Calculation:$StandingGF /$StangingGA"
It is not actually putting the values in $StandingGF and $StandingGA in the equation...
Does anyone know how I might approach this??
Any help is greatly appreciated. Thanks for your time!