Trevor
|
| Posted: 09/13/2002, 4:50 PM |
|
I would bet money that someone has done exactly this:
I am using PHP and I want to populate a list box with month items (e.g. August-2002, July-2002, June-2002 etc. etc.) These months will be for 12 months in the past and 12 months in the future from the current month. This will give a listbox with 24 items. The selected months will of course be stored in a database.
I am presuming jacascript to create the dates and PHP to fill the box??????
Please help!
|
|
|
 |
RonB
|
| Posted: 09/14/2002, 10:59 AM |
|
I'm sure you could do something like that in javascript but wouldn't it be easier, and more flexible, to just create a table called month, containing 12 months and a table called year, containing years, and make two listboxes> one with months and one with years?
|
|
|
 |
Trevor
|
| Posted: 09/14/2002, 8:01 PM |
|
Thanks for the reply RonB! A good solution except that it requires the user to select twice (month and year). I got the solution I wanted from Walker at CodeCharge and maybe someone else will want to do this sometime so here is the solution:
In the list values of the listbox, put the following PHP code:
". date(m, mktime (0,0,0,date("m")+2,date("d"), date("Y"))) .";
". date('F - Y', mktime (0,0,0,date("m")+2,date("d"), date("Y"))) .";
". date(m, mktime (0,0,0,date("m")+1,date("d"), date("Y"))) .";
". date('F - Y', mktime (0,0,0,date("m")+1,date("d"), date("Y"))) .";
". date(m, mktime (0,0,0,date("m"),date("d"), date("Y"))) .";
". date('F - Y', mktime (0,0,0,date("m"),date("d"), date("Y"))) .";
" .date(m, mktime (0,0,0,date("m")-1,date("d"), date("Y"))) .";
". date('F - Y', mktime (0,0,0,date("m")-1,date("d"), date("Y"))) .";
". date(m, mktime (0,0,0,date("m")-2,date("d"), date("Y"))) .";
". date('F - Y', mktime (0,0,0,date("m")-2,date("d"), date("Y"))) .";
etc. etc. Thanks to Walker!
|
|
|
 |
|