Forums

PHP

This topic is locked

Loop Problem??? Please URGENT

Posted 27 Nov 2003 23:09:36
1
has voted
27 Nov 2003 23:09:36 Peter R posted:
Hello,

I've got a URL created by a form that looks like this:

<pre id=code><font face=courier size=2 id=code>www.domain.com/page.php?tw_1=432047&tw_2=21&tw_3=66.......con't......&username=bob</font id=code></pre id=code>

Then page.php is supposed to use the following code to ADD-up the values of the variables together.(The variables are actually "seconds". Then this code is supposed to take the ADDED-up values and divide it up into minutes and seconds and display this in HH:MM format.

For some reason though it only comes out as 0's. I believe everything after "//end while" is fine because I currently use that exact code elsewhere and it works. I think the problem is with the loop that adds up the values of the variables. Do you see what's wrong with this? I tried putting a $ infront of the second "iterator" but that didn't help.

<pre id=code><font face=courier size=2 id=code>
&lt;?php
$iteratore = 1;
$total = 0;
while(isset($_GET['tw_'.$iterator])) {
$total += $_GET['tw_'.iterator];
$iterator++;
} //end while
$hours = floor($total/3600);
$remaining_seconds = $total - $hours*3600;
$minutes = floor($remaining_seconds/60);
if ($minutes &lt; 10) { echo "&lt;strong&gt;$hours:0$minutes&lt;/strong&gt;"; } else { echo "&lt;strong&gt;$hours:$minutes&lt;/strong&gt;"; }
?&gt;
</font id=code></pre id=code>

Peter

Peter

Replies

Replied 28 Nov 2003 00:39:23
28 Nov 2003 00:39:23 Peter R replied:
Hey,

Problem solved. Two typos. The e at the end of the first "iterator"e. And missing a $ infront of the third iterator.

Thanks

Peter

Reply to this topic