title: Creating recurring dates in PHP based on current date, and boolean for done or not
body: <p>Ello,</p>
  
  <p>I am struggling with some date troubles here in PHP/MySql. I have a form that offers the recurrence of a payment yearly,quarterly,monthly,bi-weekly,or weekly and I need to be able to track when payments are made.</p>
  
  <p>So for example, if something is added on Monday March 8th (that's the date it is being entered), recurring Weekly on Thursdays (the user would only see a dropdown offering days of the week -- as the recurrence is weekly), it would enter the 52 (weekly) due dates into the db (julian/whatever is easiest), and mark the first 9 of them paid (since those days are past); the rest entered but marked unpaid.</p>
  
  <p>I have a table that would have each due_date entry, with a link to the payment detail, and a Boolean field paid/not paid. </p>
  
  <p>So in the above example, the payments table would look something like:</p>
  
  <pre><code>id | pmnt_id | due_date | is_paid
  1  |  0023   | 01/07/10 | 1
  2  |  0023   | 01/14/10 | 1
  3  |  0023   | 01/21/10 | 1
  10 |  0023   | 03/25/10 | 0
  11 |  0023   | 04/01/10 | 0
  </code></pre>
  
  <p>etc...</p>
  
  <p>The problem is, well, everything. The calendaring system is so effed up, that there seems no real logical/straightforward way to do this. I've been racking my brain, searching goggle and php date manual all morning, and I'm just getting more confused. </p>
  
  <p>Any ideas/suggestions/pointers would be greatly appreciated.</p>
  
  <p>Cheers.</p>
  
  <hr>
  
  <p>[snip]</p>
  
  <pre><code>$startDate = strtotime("$currentDay $currentMonthFull $currentYear");
  $stTimeFormatted = strftime('%d/%m/%Y',$startDate);
  $numPmnts = ($totalWeeks-$currentWeek);
  for($i=0;$i&lt;$numPmnts;$i++){
      $ddates=array(
      'sched_pay_id'=&gt;$pmntID,
      'due_date'=&gt;date('m/d/y', strtotime('+'.$i.' week', $startDate)),
      'is_paid'=&gt;0,
      );
      $this-&gt;db-&gt;insert('sched_payments',$ddates);
  }
  </code></pre>