So basically what I'm doing is creating php script which prints a table and updates and calculates the values depending on what is input into the form.
So I have a separate HTML file which contains the form, which passes 3 variables:
$tempStart
$tempEnd
$windSpeed
then I have a created a function which is used in each field of the table as follows:
function windChillCalc(&$Twc, $Temp, $Wind)
{
$Twc = 13.12 + 0.6215*$Temp - (11.37*(pow($Wind, 0.16))) + (0.3965*$Temp*(pow($Wind, 0.16)));
}
The full script is as follows:
<?php
function windChillCalc(&$Twc, $Temp, $Wind)
{
$Twc = 13.12 + 0.6215*$Temp - (11.37*(pow($Wind, 0.16))) + (0.3965*$Temp*(pow($Wind, 0.16)));
}
?>
<html>
<head>
<title>Wind Chill Temperature Table</title>
</head>
<?php
extract($_REQUEST);
print "<h1>Wind Chill Temperature Table</h1>";
if(!empty($tempStart) && !empty($tempEnd) && !empty($windSpeed))
{
print "<h3>Air Temperature from: ".$tempStart."°C to ".$tempEnd."°C</h3>";
print "<h3>For Wind Speed from 7 km/h to ".$windSpeed." km/h</h3>";
}
else
print "<h2>Air Temperature START is not numeric</h2><br />";
$tablecolor="white";
$headercolor="#00ffff";
$windcolor="red";
$tempcolor="yellow";
$cTemp=$tempStart;
$cWindSpeed="7";
windChillCalc($Twc,$cTemp,$cWindSpeed);
print "<table border=1><tr>";
print "<th width=275 bgcolor=$headercolor>Wind Speed (km/h)/Air Temp.</th>";
for ($cTemp = $tempStart; $cTemp < $tempEnd; $cTemp+=5){
print "<th width=100 bgcolor=$headercolor>$cTemp</th>";
}
if ($cTemp != $tempEnd){
print "<th width=100 bgcolor=$headercolor>$tempEnd</th></tr>";
$cTemp = $tempStart;
}
for ($cWindSpeed = 7; $cWindSpeed < $windSpeed; $cWindSpeed+=0.5){
print "<tr>";
print "<td align=center bgcolor=$windcolor>$cWindSpeed</td>";
for ($cTemp = $tempStart; $cTemp < $tempEnd; $cTemp+=5) {
print "<td align=center bgcolor=$tempcolor>$Twc</td>";
}
if ($cTemp != $tempEnd){
print "$<td align=center bgcolor=$tempcolor>$Twc</tb></tr>";
$cTemp = $tempStart;
}
}
if ($cWindSpeed != $windSpeed){
print "<td align=center bgcolor=$windcolor>$windSpeed</td>";
for ($cTemp = $tempStart; $cTemp < $tempEnd; $cTemp+=5) {
print "<td align=center bgcolor=$tempcolor>$Twc</td>";
}
if ($cTemp != $tempEnd){
print "$<td align=center bgcolor=$tempcolor>$Twc</tb></tr>";
$cTemp = $tempStart;
}
}
print "</tr>";
print "</table>";
?>
</body>
</html>
What ends up happening is it creates a table that looks like this:
https://i.stack.imgur.com/Iv00i.png
The header and the left most column is correct, but it seems to only calculate the yellow cells with the same set of variables. It doesn't update the variables according to what is in the header and left most column to the formula.
So basically, every yellow cell is calculated using:
$Wind = 7
$Temp = -5
Please help me guys! I need to fix this in the next few hours, this is my last hope. Thanks!