Note that there are some explanatory texts on larger screens.

plurals
  1. POVariable not passing/updating in PHP loop
    primarykey
    data
    text
    <p>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.</p> <p>So I have a separate HTML file which contains the form, which passes 3 variables:</p> <pre><code>$tempStart $tempEnd $windSpeed </code></pre> <p>then I have a created a function which is used in each field of the table as follows:</p> <pre><code> function windChillCalc(&amp;$Twc, $Temp, $Wind) { $Twc = 13.12 + 0.6215*$Temp - (11.37*(pow($Wind, 0.16))) + (0.3965*$Temp*(pow($Wind, 0.16))); } </code></pre> <p>The full script is as follows:</p> <pre><code>&lt;?php function windChillCalc(&amp;$Twc, $Temp, $Wind) { $Twc = 13.12 + 0.6215*$Temp - (11.37*(pow($Wind, 0.16))) + (0.3965*$Temp*(pow($Wind, 0.16))); } ?&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Wind Chill Temperature Table&lt;/title&gt; &lt;/head&gt; &lt;?php extract($_REQUEST); print "&lt;h1&gt;Wind Chill Temperature Table&lt;/h1&gt;"; if(!empty($tempStart) &amp;&amp; !empty($tempEnd) &amp;&amp; !empty($windSpeed)) { print "&lt;h3&gt;Air Temperature from: ".$tempStart."&amp;degC to ".$tempEnd."&amp;degC&lt;/h3&gt;"; print "&lt;h3&gt;For Wind Speed from 7 km/h to ".$windSpeed." km/h&lt;/h3&gt;"; } else print "&lt;h2&gt;Air Temperature START is not numeric&lt;/h2&gt;&lt;br /&gt;"; $tablecolor="white"; $headercolor="#00ffff"; $windcolor="red"; $tempcolor="yellow"; $cTemp=$tempStart; $cWindSpeed="7"; windChillCalc($Twc,$cTemp,$cWindSpeed); print "&lt;table border=1&gt;&lt;tr&gt;"; print "&lt;th width=275 bgcolor=$headercolor&gt;Wind Speed (km/h)/Air Temp.&lt;/th&gt;"; for ($cTemp = $tempStart; $cTemp &lt; $tempEnd; $cTemp+=5){ print "&lt;th width=100 bgcolor=$headercolor&gt;$cTemp&lt;/th&gt;"; } if ($cTemp != $tempEnd){ print "&lt;th width=100 bgcolor=$headercolor&gt;$tempEnd&lt;/th&gt;&lt;/tr&gt;"; $cTemp = $tempStart; } for ($cWindSpeed = 7; $cWindSpeed &lt; $windSpeed; $cWindSpeed+=0.5){ print "&lt;tr&gt;"; print "&lt;td align=center bgcolor=$windcolor&gt;$cWindSpeed&lt;/td&gt;"; for ($cTemp = $tempStart; $cTemp &lt; $tempEnd; $cTemp+=5) { print "&lt;td align=center bgcolor=$tempcolor&gt;$Twc&lt;/td&gt;"; } if ($cTemp != $tempEnd){ print "$&lt;td align=center bgcolor=$tempcolor&gt;$Twc&lt;/tb&gt;&lt;/tr&gt;"; $cTemp = $tempStart; } } if ($cWindSpeed != $windSpeed){ print "&lt;td align=center bgcolor=$windcolor&gt;$windSpeed&lt;/td&gt;"; for ($cTemp = $tempStart; $cTemp &lt; $tempEnd; $cTemp+=5) { print "&lt;td align=center bgcolor=$tempcolor&gt;$Twc&lt;/td&gt;"; } if ($cTemp != $tempEnd){ print "$&lt;td align=center bgcolor=$tempcolor&gt;$Twc&lt;/tb&gt;&lt;/tr&gt;"; $cTemp = $tempStart; } } print "&lt;/tr&gt;"; print "&lt;/table&gt;"; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>What ends up happening is it creates a table that looks like this:</p> <p><a href="http://i.stack.imgur.com/Iv00i.png" rel="nofollow">http://i.stack.imgur.com/Iv00i.png</a></p> <p>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.</p> <p>So basically, every yellow cell is calculated using:</p> <pre><code>$Wind = 7 $Temp = -5 </code></pre> <p>Please help me guys! I need to fix this in the next few hours, this is my last hope. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload