基本的に私がやっていることは、テーブルを出力し、フォームに入力された内容に応じて値を更新および計算するphpスクリプトを作成することです。
したがって、3 つの変数を渡すフォームを含む別の HTML ファイルがあります。
$tempStart
$tempEnd
$windSpeed
次に、テーブルの各フィールドで次のように使用される関数を作成しました。
function windChillCalc(&$Twc, $Temp, $Wind)
{
$Twc = 13.12 + 0.6215*$Temp - (11.37*(pow($Wind, 0.16))) + (0.3965*$Temp*(pow($Wind, 0.16)));
}
完全なスクリプトは次のとおりです。
<?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>
最終的には、次のようなテーブルが作成されます。
http://i.stack.imgur.com/Iv00i.png
ヘッダーと一番左の列は正しいですが、同じ変数セットを持つ黄色のセルのみを計算しているようです。ヘッダーの内容に従って変数を更新せず、数式の左端の列にします。
したがって、基本的に、すべての黄色のセルは次を使用して計算されます。
$Wind = 7
$Temp = -5
みんな助けてください!数時間以内にこれを修正する必要があります。これが私の最後の希望です。ありがとう!