Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 27th, 2003, 04:24 PM
Registered User
 
Join Date: Nov 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with Loop?? Please URGENT

Hello,

I've got a URL created by a form that looks like this:
(with www not ***)

http://***.domain.com/page.php?tw_1=432047&tw_2=21&tw_3=66.....con't.... .

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? THANKS!

<?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 < 10) { echo "<strong>$hours:0$minutes</strong>"; } else { echo "<strong>$hours:$minutes</strong>"; }
?>


Peter

 
Old November 27th, 2003, 06:37 PM
Registered User
 
Join Date: Nov 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Have a problem in For-each loop LeoMathew XSLT 2 July 16th, 2008 05:20 AM
While loop urgent mikedeepak Classic ASP Databases 1 October 7th, 2005 03:04 AM
URGENT:For loop jyoti_khera XSLT 3 October 19th, 2004 08:04 AM
while loop problem shoakat Classic ASP Databases 1 September 21st, 2004 03:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.