mysql - Recurring Tasks with PHP -
i need solution recurring tasks on date.
i have reminder table on database. have these structure;
id, contract_id, remindtask, remind_startdate, remind_enddate, remind_repeat, remind_repeatunit, remind_responsible [note: remind_repeat , remind_repeatunit columns using on date("d.m.y", strtotime(date +1 day))]
i want make agenda @ http://bootsnipp.com/snippets/featured/agenda except time column. want use first reminder of representation checkbox on other date("d.m.y", strtotime($calendar_date +$repeat $repeatunit)) display in form.
i write code , approached want.
$conn_reminder_min_startdate = mysql_query("select * reminder order remind_startdate asc"); $get_reminder_min_startdate = mysql_fetch_array($conn_reminder_min_startdate); $remind_min_startdate = $get_reminder_min_startdate['remind_startdate']; $conn_reminder_max_enddate = mysql_query("select * reminder order remind_enddate desc"); $get_reminder_max_enddate = mysql_fetch_array($conn_reminder_max_enddate); $remind_max_enddate = $get_reminder_max_enddate['remind_enddate']; $calendar_firstday = $remind_min_startdate; $calendar_lastday = $remind_max_enddate; echo 'calendar first day: ' . $calendar_firstday . ' | calendar last day: ' . $calendar_lastday; ($i = 1; $i<60; $i++){ // not find loop between dates set up, forced run loop numerically. echo "<h4>" . date("d.m.y", strtotime($calendar_firstday)) . '</h4>'; $conn_reminder_list = mysql_query("select * reminder order remind_startdate asc"); while($get_reminder_list = mysql_fetch_array($conn_reminder_list)){ $contract_id = $get_reminder_list['contract_id']; $contract_remindtask = $get_reminder_list['contract_remindtask']; $remind_startdate = $get_reminder_list['remind_startdate']; $remind_repeat = $get_reminder_list['remind_repeat']; $remind_repeat_unit = $get_reminder_list['remind_repeat_unit']; if($remind_startdate == $calendar_firstday) { echo '<input type="checkbox"/> ' . $contract_id . ' | ' . $contract_remindtask . '<br/>'; } else { switch ($remind_repeat_unit) { case "1": $new_startdate = date("d.m.y", strtotime($remind_startdate . '+' . $remind_repeat . ' day')); break; case "2"; $new_startdate = date("d.m.y", strtotime($remind_startdate . '+' . $remind_repeat . ' week')); break; case "3"; $new_startdate = date("d.m.y", strtotime($remind_startdate . '+' . $remind_repeat . ' month')); break; case "4"; $new_startdate = date("d.m.y", strtotime($remind_startdate . '+' . $remind_repeat . ' year')); break; } if($new_startdate == $calendar_firstday) { echo $contract_id . ' | ' . $contract_remindtask . '<br/>'; } } } $calendar_firstday = date("d.m.y", strtotime($calendar_firstday . '+1 day')); echo '<br/>'; }
i'll result;
calendar first day: 2016-03-01 | calendar last day: 2016-07-15
### 01.03.2016 ### 4 | test3 checkbox 4 | test4 checkbox ### 02.03.2016### ### 03.03.2016### 4 | test3 **without checkbox** 4 | test4 **without checkbox** ### 04.03.2016### ### 05.03.2016### 4 | test 5 **without checkbox** ### 06.03.2016### ### 07.03.2016### ### 08.03.2016### ### 09.03.2016### ### 10.03.2016### ### 11.03.2016### ### 12.03.2016### ### 13.03.2016### ### 14.03.2016### ### 15.03.2016### ### 16.03.2016### ### 17.03.2016### ### 18.03.2016### ### 19.03.2016### ### 20.03.2016### ### 21.03.2016### ### 22.03.2016### ### 23.03.2016### ### 24.03.2016### ### 25.03.2016### ### 26.03.2016### ### 27.03.2016### ### 28.03.2016### ### 29.03.2016### ### 30.03.2016### ### 31.03.2016### ### 01.04.2016### ### 02.04.2016### ###03.04.2016### ###04.04.2016### ### 05.04.2016### ### 06.04.2016### ### 07.04.2016### ### 08.04.2016### ### 09.04.2016### ### 10.04.2016### ### 11.04.2016### ### 12.04.2016### ### 13.04.2016### ### 14.04.2016### ### 15.04.2016### ### 16.04.2016### ### 17.04.2016### ### 18.04.2016### ### 19.04.2016### ### 20.04.2016### 4 | test1 **without checkbox** ### 21.04.2016### 4 | test2 **without checkbox** ### 22.04.2016### ### 23.04.2016### ### 24.04.2016### ### 25.04.2016### ### 26.04.2016### ### 27.04.2016### ### 28.04.2016###
test 3 & test 4 views normal test5, test1 , test2 isn't.
note: test1 remind_startdate 2016-04-18 , have on day with checkbox, too. test5 remind_startdate 2016-03-03 , have on day with checkbox, too. test2 remind_startdate 2016-04-19 , have on day with checkbox, too. without checkbox views ok.
all make me happy. in advance.
Comments
Post a Comment