Code: Select all
// i want to show dynamically 6 months including current month in a combo box.
// like when October will be over combo box will show November to April.
// please help me..code can be in php or javascript....
Moderator: General Moderators
Code: Select all
// i want to show dynamically 6 months including current month in a combo box.
// like when October will be over combo box will show November to April.
// please help me..code can be in php or javascript....
Code: Select all
$month = mktime();
echo date('M',$month).'<br />';
for($i = 0; $i < 5; $i++) {
$month = strtotime(date('d-M-Y',$month).' + 1 Month');
echo date('M',$month).'<br />';
}
Mark Baker wrote:This logic may help:Code: Select all
$month = mktime(); echo date('M',$month).'<br />'; for($i = 0; $i < 5; $i++) { $month = strtotime(date('d-M-Y',$month).' + 1 Month'); echo date('M',$month).'<br />'; }
Code: Select all
// your code is nice but i have to implement within a combo box
// so what to do?
<select name="month" id="month">
// any condition for showing six month
<?php for($i=1; $i<=6; $i++){?>
<option value="<?php echo $i;?>"><?php echo $i;?></option>
<?php } ?>
</select>