php-general | 2001072
Date: 07/31/01
- Next message: Andrew Sterling Hanenkamp: "[PHP] Re: Syntax Error On Line 1"
- Previous message: Matthew Loff: "RE: [PHP] Trouble creating a list on months"
- In reply to: Mario A. Salinas: "[PHP] Trouble creating a list on months"
- Next in thread: Andreas D . Landmark: "Re: [PHP] Failure Configuring 4.0.6 on SuSE 7.1"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Oops! I forgot to include the parameter...
function month_select($month)
{
echo "<select name=\"month\">\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<option>" . $month_names[$month] .
"</option>\n";
$month = ($month == 12? 1 : $month + 1);
}
echo "</select>\n";
}
I didn't get a chance to test this, but you get the idea...
Good luck.
-----Original Message-----
From: Mario A. Salinas [mailto:masPHP <email protected>]
Sent: Tuesday, July 31, 2001 8:33 PM
To: php-general <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 <select> should be as follows:
<select>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
<option>January</option>
<option>Februrary</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
</select>
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:
<select>
<option>July</option>
<option>August</option>
<option>October</option>
<option>October</option>
<option>December</option>
<option>December</option>
<option>January</option>
<option>March</option>
<option>March</option>
<option>May</option>
<option>May</option>
<option>July</option>
</select>
The function gets called as follows:
----------------------------------------------------
<? month_select($month); ?>
----------------------------------------------------
$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 ("<select name=month
style=\"font-family:Verdana,Helvetica;font-size:8pt;\">");
for($x=1;$x<=12;$x++) {
$month = $x + $offset;
if($month>12) $month -= 12;
echo("<option value=$month");
if($month==$default) echo(" selected");
echo(">".date("F",mktime(0,0,0,$month))."</option>");
}
echo ("</select>");
}
----------------------------------------------------
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:mas <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: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Andrew Sterling Hanenkamp: "[PHP] Re: Syntax Error On Line 1"
- Previous message: Matthew Loff: "RE: [PHP] Trouble creating a list on months"
- In reply to: Mario A. Salinas: "[PHP] Trouble creating a list on months"
- Next in thread: Andreas D . Landmark: "Re: [PHP] Failure Configuring 4.0.6 on SuSE 7.1"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

