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));
}
}