2

I need a solution that about recurring tasks on its 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 and remind_repeatunit columns for using on date("d.m.Y", strtotime(date +1 day))]

I want to make agenda like at http://bootsnipp.com/snippets/featured/agenda EXCEPT time column. I want to use the first reminder of representation with a checkbox on but other date("d.m.Y", strtotime($calendar_date +$repeat $repeatunit)) display will be in the form.

I write some code and I approached what I want.

$conn_reminder_min_startdate = mysql_query("SELECT * FROM reminder ORDER BY 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 * FROM reminder ORDER BY 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;


for ($i = 1; $i<60; $i++){ // I could not find a loop between the dates to be set up, I was forced to run the loop numerically.

echo "<h4>" . date("d.m.Y", strtotime($calendar_firstday)) . '</h4>';

$conn_reminder_list = mysql_query("SELECT * FROM reminder ORDER BY 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 get this result;

Calendar First Day: 2016-03-01 | Calendar Last Day: 2016-07-15

### 01.03.2016 ###
4 | test3 with checkbox
4 | test4 with 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 is normal but test5, test1 and test2 isn't.

Note: test1 remind_startdate is 2016-04-18 and have to be on that day with checkbox, too. test5 remind_startdate is 2016-03-03 and have to be on that day with checkbox, too. test2 remind_startdate is 2016-04-19 and have to be on that day with checkbox, too. But without checkbox views is ok.

All your help will make me happy. Thanks in advance.

Pecado
  • 35
  • 7
  • 3
    Off topic, but please do yourself a favour and stop using the obsolete `mysql_xxx()` functions. They have been considered obsolete for over a decade and have now been removed completely from the latest versions of PHP. You need to urgently switch your code to the newer PDO library if you want it to run in all current PHP versions, let alone continue working in the future. – Spudley Apr 19 '16 at 18:55
  • I will consider it. I plan to change the PHP version on my computer. But I need to finish a project before doing so. After that I intend to renew using the PDO library. My question will be available in the new system. Therefore, I will continue to search for solutions. – Pecado Apr 19 '16 at 20:07
  • I solved my problem. If anyone want to know, just ask please. – Pecado Apr 27 '16 at 04:45

0 Answers0