[PHP] need help breaking out of loop.
Hi, I'm working of a PHP-MySQL-planning system for a newspaper. I want to add dates and number for each issue. I have to following code, where $current_date is a unix timestamp. If $current_date is a Saturday or Sunday, I want to quit the current execution of the loop and contiune with the next date. But when the if- clause that checks if $issue_day_of_week is Sunday or Saturday is included in my while-loop, everything stalls. Without it, everything goes smooth. What am I missing? while ($i = $number_of_days) { $issue_date = strftime(%Y-%m-%d, $current_date); $issue_month = date(m, $current_date); $issue_day = date(d, $current_date); $issue_day_of_week = date(l, $current_date); // Check that $issue_date isn't Saturday or Sunday if ($issue_day_of_week == Sunday | $issue_day_of_week == Saturday) { continue; } if ($issue_month == 1 $issue_day == 1) { $issue_number = 1; $current_date = $current_date + 86400; $i++; $issue_number++; continue; } $current_date = $current_date + 86400; $i++; $issue_number++; } -- anders thoresson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] need help breaking out of loop.[Scanned]
Anders, Are you missing a '|' in the if condition? Michael Egan -Original Message- From: anders thoresson [mailto:[EMAIL PROTECTED] Sent: 26 June 2003 12:01 To: [EMAIL PROTECTED] Subject: [PHP] need help breaking out of loop.[Scanned] Hi, I'm working of a PHP-MySQL-planning system for a newspaper. I want to add dates and number for each issue. I have to following code, where $current_date is a unix timestamp. If $current_date is a Saturday or Sunday, I want to quit the current execution of the loop and contiune with the next date. But when the if- clause that checks if $issue_day_of_week is Sunday or Saturday is included in my while-loop, everything stalls. Without it, everything goes smooth. What am I missing? while ($i = $number_of_days) { $issue_date = strftime(%Y-%m-%d, $current_date); $issue_month = date(m, $current_date); $issue_day = date(d, $current_date); $issue_day_of_week = date(l, $current_date); // Check that $issue_date isn't Saturday or Sunday if ($issue_day_of_week == Sunday | $issue_day_of_week == Saturday) { continue; } if ($issue_month == 1 $issue_day == 1) { $issue_number = 1; $current_date = $current_date + 86400; $i++; $issue_number++; continue; } $current_date = $current_date + 86400; $i++; $issue_number++; } -- anders thoresson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] need help breaking out of loop.
Are you incrementing number_of_days anywhere within the loop? It looks like you have an infinite loop running. If you want to be able to move to the next date, increment you date variable. -Naintara -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] t]On Behalf Of anders thoresson Sent: Thursday, June 26, 2003 4:31 PM To: [EMAIL PROTECTED] Subject: [PHP] need help breaking out of loop. Hi, I'm working of a PHP-MySQL-planning system for a newspaper. I want to add dates and number for each issue. I have to following code, where $current_date is a unix timestamp. If $current_date is a Saturday or Sunday, I want to quit the current execution of the loop and contiune with the next date. But when the if- clause that checks if $issue_day_of_week is Sunday or Saturday is included in my while-loop, everything stalls. Without it, everything goes smooth. What am I missing? while ($i = $number_of_days) { $issue_date = strftime(%Y-%m-%d, $current_date); $issue_month = date(m, $current_date); $issue_day = date(d, $current_date); $issue_day_of_week = date(l, $current_date); // Check that $issue_date isn't Saturday or Sunday if ($issue_day_of_week == Sunday | $issue_day_of_week == Saturday) { continue; } if ($issue_month == 1 $issue_day == 1) { $issue_number = 1; $current_date = $current_date + 86400; $i++; $issue_number++; continue; } $current_date = $current_date + 86400; $i++; $issue_number++; } -- anders thoresson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.491 / Virus Database: 290 - Release Date: 6/18/2003 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need help breaking out of loop.
On Thu, 26 Jun 2003 13:00:45 +0200, you wrote: What am I missing? At first glance while ($i = $number_of_days) { $issue_date = strftime(%Y-%m-%d, $current_date); $issue_month = date(m, $current_date); $issue_day = date(d, $current_date); $issue_day_of_week = date(l, $current_date); // Check that $issue_date isn't Saturday or Sunday if ($issue_day_of_week == Sunday | $issue_day_of_week == Saturday) if ($issue_day_of_week == 'Sunday' || $issue_day_of_week == 'Saturday') { continue; } if ($issue_month == 1 $issue_day == 1) if ($issue_month == 1 $issue_day == 1) { $issue_number = 1; $current_date = $current_date + 86400; $i++; $issue_number++; continue; } $current_date = $current_date + 86400; $i++; $issue_number++; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php