Insert Date Ranges into <input> within PHP...?

Hello, I am not versed enough to formulate a proper question (using the correct terminology etc) so please bear with me. I have a form that contains the date range manually, and the entire form is wrapped inside of PHP:
[php]
$formData = ’


<form action="…etc.
[/php]

I want to insert the dynamic php for date range:
[php]

<?php for ($i=1; $i <= 12; $i++): echo '' . date('M', mktime(0,0,0,$i)) . ''; endfor; ?>

[/php]

Obviously this does not work because the form is already inside of <?php… So my question is: how can I accomplish this? I don’t know how to ask and that makes google’ing for an answer much harder than I thought.

Thanks for any help!

You can use .= to append to your $formData string

[php]
$formData = ’


<form action="…etc.’;
for ($i=1; $i <= 12; $i++):
	$formData .= '<option  value="' . sprintf('%02d',$i) . '">' . date('M', mktime(0,0,0,$i)) . '</option>';
endfor;

$formData .= ‘’;
[/php]

That’s great, thank you very much!

Sponsor our Newsletter | Privacy Policy | Terms of Service