I need get values between two dates (including first and last ones). for example i've got form with two dates:
2013-12-01
2013-12-08
and i need get list/array etc. which will looks like:
2013-12-01
2013-12-02
2013-12-03
2013-12-04
2013-12-05
2013-12-06
2013-12-07
2013-12-08
and then insert them all into column in MySQL but in individual lines.So it should looks like this:
1
__________
1 ; 2013-12-01
; ----------
2 ; 2013-12-02
; ----------
3 ; 2013-12-03
; ----------
4 ; 2013-12-04
; ----------
5 ; 2013-12-05
; ----------
6 ; 2013-12-06
; ----------
7 ; 2013-12-07
; ----------
8 ; 2013-12-08
I've tried:
$id = $_POST['id'];
$from = $_POST['from'];
$to = $_POST['to'];
$a = new DateTime($from);
$b = new DateTime($to);
$b = $b->modify( '+1 day' );
$period = new DatePeriod($a, new DateInterval('P1D'), $b);
foreach($period as $dt) {
$to = $dt->format('Y-m-d');
$insertquery = mysql_query(" INSERT INTO `unavailable` (`$id`) VALUES (`$to`) ");
}
but it's not working...