RE: [PHP] Trouble creating a list on months

2001-08-01 Thread Mark Roedel

> -Original Message-
> From: Mario A. Salinas [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 31, 2001 7:33 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Trouble creating a list on months
> 
> 
> The actual function is as follows:
> 
> function month_select($default=1) {
> 
>$offset = date("n")-1;  // value used to be 'm'
> 
>echo (" style=\"font-family:Verdana,Helvetica;font-size:8pt;\">");
>for($x=1;$x<=12;$x++) {
>  $month = $x + $offset;
>  if($month>12) $month -= 12;
>  echo("  if($month==$default) echo(" selected");
>  echo(">".date("F",mktime(0,0,0,$month))."");

Try changing this to

echo ">".date("F",mktime(0,0,0,$month,1))."");

>}
>echo ("");
> }
> 
> 
> Any Ideas what could be causing the problem?  I'm new to this
> and have been staring at it for a while.  Your help is greatly 
> appreciated.

Actually, I'd expect that if you try your code again today, it works
just like you'd expect.

Mktime() uses the current (local date/time) value for any parameters
that you leave out.  Since you were running this on July 31st, that
means your mktime call was trying to build timestamps for February 31st
(which is actually in March), April 31st (actually in May), and so on.


---
Mark Roedel ([EMAIL PROTECTED])  ||  "There cannot be a crisis next week.
Systems Programmer / WebMaster  ||   My schedule is already full."
 LeTourneau University  ||-- Henry Kissinger


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Trouble creating a list on months

2001-07-31 Thread Matthew Loff


Oops!  I forgot to include the parameter...

function month_select($month)
{
echo "\n";

$month_names = array(1 => "January", 2 => "February", 3 =>
"March", 
4 => "April", 5 => "May", 6 => "June", 7 => "July", 
8 => "August", 9 => "September", 10 => "October", 
11 => "November", 12 => "December");

if(!isset($month)) $month = (int)strftime("%m");

for($num_months = 0; $num_months < 12; $num_months++)
{
echo "\t" . $month_names[$month] .
"\n";
$month = ($month == 12? 1 : $month + 1);
}

echo "\n";
}

I didn't get a chance to test this, but you get the idea...

Good luck.


-Original Message-
From: Mario A. Salinas [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, July 31, 2001 8:33 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Trouble creating a list on months


Hello everyone,

This is my first posting.  I'm hoping someone can help figure this 
out.  I'm using a GNU licensed calendar but there is a bug in it's 
process for building a list of months.

The list is supposed to build a list of months starting with the 
current month and adding 11 months to the list.  In theory, If this 
is July the  should be as follows:


July
August
September
October
November
December
January
Februrary
March
April
May
June


The process of building this list is done in a defined function in a 
'Required' inclusion of a file.

The problem is that the list gets built as follows:


July
August
October
October
December
December
January
March
March
May
May
July


The function gets called as follows:









$month is defined just before the (above) call as follows:

if(!isset($month)) $month=date("n");






The actual function is as follows:

function month_select($default=1) {

   $offset = date("n")-1;  // value used to be 'm'

   echo ("");
   for($x=1;$x<=12;$x++) {
 $month = $x + $offset;
 if($month>12) $month -= 12;
 echo("".date("F",mktime(0,0,0,$month))."");
   }
   echo ("");
}




Any Ideas what could be causing the problem?  I'm new to this and 
have been staring at it for a while.  Your help is greatly 
appreciated.

Thanks in advance,

Mario Salinas






-- 

===
  The Internet is a Jungle...  We can guide you through it safely!
===
  Amazon Networks
  1-818/954-0131
  mailto:[EMAIL PROTECTED]
  http://www.amazon-networks.com
===
  A firm that specializes in enabling large and small companies
  to Dominate the Internet through the development of intelligent
  Intranet/Extranet solutions and Search Engine Registrations.
===
"It's because light travels faster than sound that some people seem very
bright, until you hear them speak"
 
-- Anonymous
===

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Trouble creating a list on months

2001-07-31 Thread Matthew Loff


Try this:

function month_list()
{
echo "\n";

$month_names = array(1 => "January", 2 => "February", 3 =>
"March", 
4 => "April", 5 => "May", 6 => "June", 7 => "July", 
8 => "August", 9 => "September", 10 => "October", 
11 => "November", 12 => "December");

$month = (int)strftime("%m");

for($num_months = 0; $num_months < 12; $num_months++)
{
echo "\t" . $month_names[$month] .
"\n";
$month = ($month == 12? 1 : $month + 1);
}

echo "\n";
}


-Original Message-
From: Mario A. Salinas [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, July 31, 2001 8:33 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Trouble creating a list on months


Hello everyone,

This is my first posting.  I'm hoping someone can help figure this 
out.  I'm using a GNU licensed calendar but there is a bug in it's 
process for building a list of months.

The list is supposed to build a list of months starting with the 
current month and adding 11 months to the list.  In theory, If this 
is July the  should be as follows:


July
August
September
October
November
December
January
Februrary
March
April
May
June


The process of building this list is done in a defined function in a 
'Required' inclusion of a file.

The problem is that the list gets built as follows:


July
August
October
October
December
December
January
March
March
May
May
July


The function gets called as follows:









$month is defined just before the (above) call as follows:

if(!isset($month)) $month=date("n");






The actual function is as follows:

function month_select($default=1) {

   $offset = date("n")-1;  // value used to be 'm'

   echo ("");
   for($x=1;$x<=12;$x++) {
 $month = $x + $offset;
 if($month>12) $month -= 12;
 echo("".date("F",mktime(0,0,0,$month))."");
   }
   echo ("");
}




Any Ideas what could be causing the problem?  I'm new to this and 
have been staring at it for a while.  Your help is greatly 
appreciated.

Thanks in advance,

Mario Salinas






-- 

===
  The Internet is a Jungle...  We can guide you through it safely!
===
  Amazon Networks
  1-818/954-0131
  mailto:[EMAIL PROTECTED]
  http://www.amazon-networks.com
===
  A firm that specializes in enabling large and small companies
  to Dominate the Internet through the development of intelligent
  Intranet/Extranet solutions and Search Engine Registrations.
===
"It's because light travels faster than sound that some people seem very
bright, until you hear them speak"
 
-- Anonymous
===

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] To
contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]