Counting Problem?

I have an event calendar that stores the dates in a MySQL database in the format of “2010-11-01”.

The calendar code loops through the days of the month and writes any event that it finds on that day.

Problem is that the first 9 days aren’t showing any events even when they have them. My guess is because it is looking for 1 and finding 01 in the database, any ideas?

Any help is greatly appreciated. Thanks.

Are you storing the data in a DATE datatype column? Can you post the query you’re using that is missing dates too? :wink:

Yes it is a DATE field. Here is the code:


  for ($i = 1; $i <= $days_in_month; $i++) {
      $days_so_far = $days_so_far + 1;
      $count_boxes = $count_boxes + 1;
      if ($_GET['month'] == $todays_month + 1) {
          if ($i == $todays_date) {
              $class = "highlighteddayboxes";
          } else {
              $class = "dayboxes";
          }
      } else {
          if ($i == 1) {
              $class = "highlighteddayboxes";
          } else {
              $class = "dayboxes";
          }
      }
      echo "<td width=\\"86\\" height=\\"75\\" class=\\"$class\\">\
";
      $link_month = $_GET['month'] - 1;
      echo "<div align='right'><span class='toprightnumber'>\
<a class='iframe' href='event_add.php?day=$i&amp;month=$link_month&amp;year=$_GET[year]'>$i</a>&nbsp;</span></div>\
";
      if (isset($events[$i])) {
          echo "<div align=\\"left\\"><span class=\\"eventinbox\\">\
";
          while (list($key, $value) = each($events[$i])) {
              echo "&nbsp;<a class='iframe2' href='event_edit.php?eventid=$value'>" . $event_info[$value]['1'] . " " . $event_info[$value]['0'] . "</a>\
<br>\
";
          }
          echo "</span></div>\
";
      }
      echo "</td>\
";
      if (($count_boxes == 7) and ($days_so_far != (($first_day_of_month - 1) + $days_in_month))) {
          $count_boxes = 0;
          echo "</TR><TR valign=\\"top\\">\
";
      }
  }

I fixed it. It was too simple I was looking for something harder.

if (strlen($i)==1) {
$i = ‘0’.$i;
}