steviez Posted May 4, 2010 Share Posted May 4, 2010 Hi, I am making a form to track users earning for the current year and need it to display the months gone all the way up to the current month then auto add each month after that I have searched all over google but cant seem to find any help, anyone got any ideas? Thanks Quote Link to comment Share on other sites More sharing options...
Presto-X Posted May 4, 2010 Share Posted May 4, 2010 Do you mean the rest of the months in this year starting with the current month, or do you mean all of the months up to the current month? Quote Link to comment Share on other sites More sharing options...
steviez Posted May 4, 2010 Author Share Posted May 4, 2010 Do you mean the rest of the months in this year starting with the current month, or do you mean all of the months up to the current month? I need it to display all the months that have gone up to the current month, then as we move on a month it adds that too Quote Link to comment Share on other sites More sharing options...
Presto-X Posted May 4, 2010 Share Posted May 4, 2010 See if this will work for you: print "<select name='QuoteMonth'>".implode("\n",array_map(create_function('$n','return"<option value=\"$n\"".(date("n")==$n?"selected=\"selected\"":"").">".strftime("%b",strtotime("2004-$n-01"))."</option>";'),range(1,date('m'))))."</select>"; Quote Link to comment Share on other sites More sharing options...
steviez Posted May 4, 2010 Author Share Posted May 4, 2010 See if this will work for you: print "<select name='QuoteMonth'>".implode("\n",array_map(create_function('$n','return"<option value=\"$n\"".(date("n")==$n?"selected=\"selected\"":"").">".strftime("%b",strtotime("2004-$n-01"))."</option>";'),range(1,date('m'))))."</select>"; hi, thanks for your help. That seems to work as i need it but how would i get this to work in a html table to display data for each month? Thanks Quote Link to comment Share on other sites More sharing options...
Presto-X Posted May 4, 2010 Share Posted May 4, 2010 Would this work? print "<select name=\"month\">"."\n".implode("\n",array_map(create_function('$n','return" <option value=\"".strftime("%b",strtotime("2004-$n-01"))."\"".(date("n")==$n?" selected=\"selected\"":"").">".strftime("%b",strtotime("2004-$n-01"))."</option>";'),range(1,date('m'))))."\n"."</select>"; Quote Link to comment Share on other sites More sharing options...
steviez Posted May 4, 2010 Author Share Posted May 4, 2010 Would this work? print "<select name=\"month\">"."\n".implode("\n",array_map(create_function('$n','return" <option value=\"".strftime("%b",strtotime("2004-$n-01"))."\"".(date("n")==$n?" selected=\"selected\"":"").">".strftime("%b",strtotime("2004-$n-01"))."</option>";'),range(1,date('m'))))."\n"."</select>"; thats the same code as above Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.