Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 27th, 2003, 04:24 PM
Registered User
 
Join Date: Nov 2003
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old November 27th, 2003, 06:37 PM
Registered User
 
Join Date: Nov 2003
Location: , , .
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 05:12 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.