i have a date range that is just selecting a single day out of a single month
[php]
function getDatesFromRange($start, $end) {
$interval = new DateInterval(‘P1D’);
$realEnd = new DateTime($end);
$realEnd->add($interval);
$period = new DatePeriod(
new DateTime($start),
$interval,
$realEnd
);
foreach($period as $date) {
$array[] = $date->format('Y-m-d');
}
return $array;
}
// Call the function
$dates = getDatesFromRange(‘2016-04-05’, ‘2016-04-26’);
// Print the output
print_r($dates);
[/php]
this is being printed out as an array
Array ( [0] => 2016-04-05 [1] => 2016-04-06 [2] => 2016-04-07 [3] => 2016-04-08 [4] => 2016-04-09 [5] => 2016-04-10 [6] => 2016-04-11 [7] => 2016-04-12 [8] => 2016-04-13 [9] => 2016-04-14 [10] => 2016-04-15 [11] => 2016-04-16 [12] => 2016-04-17 [13] => 2016-04-18 [14] => 2016-04-19 [15] => 2016-04-20 [16] => 2016-04-21 [17] => 2016-04-22 [18] => 2016-04-23 [19] => 2016-04-24 [20] => 2016-04-25 [21] => 2016-04-26 )
i need to be able to use these dates individually so that can be inserted into my database. this is for a register for students attendance.
so as an example
2016-04-05 | 2016-04-06 | 2016-04-07 | …and so on. this date i want to come from the array
student 1 checkbox checkbox checkbox
student 2 checkbox checkbox checkbox
button to confirm
so on the form i will have a checkbox and a hidden field with the date that comes from the array
then in the DB
id | student_id | date