php代码在每次循环运行时增加日期

In my coupon column data is present like this 500,501,502 OK..

There are 3 values in coupon column so i am inserting 3 rows in database with every coupon value..

I need to insert coupondate is also an increment order of months in every loop runs...suppose above loop runs 3 times then 3 coupondate to be inserted in coupondate column.

thats it...thats why i used loop there ...

Please help to resolve my problem. I need every date to be inserted in database not last one.

$coupon = $_POST['coupon'];                     
                            $arr = explode(",", $coupon);
                            $min = min($arr);
                            $max = max($arr);
                            $startingdate = $_POST['startingdate'];                         
                            for ($i = 1; $i <= $max; $i++)
                            {                       
                             $coupondate = date("d-m-Y", strtotime(date("d-m-Y", strtotime($startingdate)) . " +" . $i .  "month")); 
                            for ($i = $min; $i <= $max; $i++)
                            {               
                $insertrow  = $database->insertRow("INSERT INTO book_issue (coupondate,coupon) VALUES (:coupondate,:coupon)", array(':coupondate'=>$coupondate,':coupon'=>$i));
           }
}
$coupon = $_POST['coupon'];                     
$arr = explode(",", $coupon);
$min = min($arr);
$max = max($arr);
$startingdate = date("d-m-Y", strtotime($_POST['startingdate']));
for ($i = 1 ; $i <= count($arr) ; $i++) {
    $count = 1;
    for ($ii = $min; $ii <= $max; $ii++) {
        $coupondate = date("d-m-Y", strtotime(date("d-m-Y", strtotime($startingdate)) . " +" . $count . " month"));
        $count++;
        $insertrow  = $database->insertRow("INSERT INTO book_issue (coupondate) VALUES (:coupondate)", array(':coupondate'=>$coupondate));
    }
}

Check the below code you missed the incrementing month value

for($i = $min; $i <= $max; $i++) {
    $dates[] = $coupon . " - " . date("d-m-Y", strtotime($startingdate . " +" . $i . " MONTHS -1 DAYS"));        
}


echo "<pre>";
print_r($dates); //out put you required
echo "</pre>";

OOP way:

$startingdate = '26-02-2015';
$date = new DateTime($startingdate);
$diff = new DateInterval('P1M');
for($i = 0; $i < 5; $i++) {
    $date->add($diff);
    print_r($date);
}

DateTime

Try this:

$startingdate = '26-02-2015';

$min = 0;
$max = 2;

for($i = $min; $i <= $max; $i++) {
    $dates[] = date("d-m-Y", strtotime($startingdate . " +" . ($i+1) . " MONTHS"));        
}


var_dump($dates);