Trouble creating a list on months

From: Date: Wed, 01 Aug 2001 00:32:59 +0000
Subject: Trouble creating a list on months
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-60540@lists.php.net to get a copy of this message
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@amazon-networks.com 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 ===============================================

« previous php.general (#60540) next »