title: How to best populate calendar with events from database
body: <p>I'm creating a calendar from scratch and can't figure out how to populate it with birthday events from a database.
  I'm not sure how to work the event data into the loop that creates the calendar days or even if that is the correct order I should be doing it?</p>
  <pre><code>$.post('fetch-event.php', function(result){  
      let days = &quot;&quot;;
      currentMonth = date.getMonth() +1;  
  
      // days of the current month and finds today's date
      for(let i = 1; i&lt;=lastDay; i++){
          if(i === new Date().getDate() &amp;&amp; date.getMonth() === new Date().getMonth()){
              days += `&lt;div class=&quot;today&quot; id=&quot;${i}/${currentMonth}/${year}&quot;&gt;${i}&lt;/div&gt;`;
          } else{
              days += `&lt;div id=&quot;${i}/${currentMonth}/${year}&quot;&gt;${i}&lt;/div&gt;`;
          }
      }
      monthDays.innerHTML = days;
  });
  </code></pre>
  <p>The 'result' of the post function produces the following.</p>
  <pre><code>[{&quot;id&quot;:&quot;1&quot;,&quot;name&quot;:&quot;Elliot&quot;,&quot;date&quot;:&quot;31/12/2020&quot;},
   {&quot;id&quot;:&quot;2&quot;,&quot;name&quot;:&quot;Phil&quot;,&quot;date&quot;:&quot;17/1/2020&quot;},
   {&quot;id&quot;:&quot;3&quot;,&quot;name&quot;:&quot;Toby&quot;,&quot;date&quot;:&quot;25/1/2021&quot;}]
  </code></pre>
  <p>Ideally if the id date of the div matches the date from the database, I want to populate the div with the name of the person in the database rather than the day number but this is a bit beyond my technical know how.</p>