Greetings everyone!

I found a script for a calender while browsing through this forum (specifically, here).

It's a good basis for what I need, but it doesn't have all the functionality.

I'd like to be able to draw from an events list (stored in a MySQL database).

I've tried my hand at it and I'm close, but not quite there.

The below kind of works. However, it only display the "selected" elements if there are 2 or less dates being pulled out from the MySQL. Also, the calendar displays additional days in the calendar (i.e. with 2 events, it shows 32 days in Jan.).

PHP Code:
// Get Event Dates
 
$query  "SELECT * FROM  kb_events";
 
$result mysql_query($query);
 while(
$row mysql_fetch_array($resultMYSQL_ASSOC))
 {
  
$events $row['date'];
  
  if (
$events==$day_num) {
   echo 
"\t\t<p class='day events'> $day_num </p>\n";
  }
  else {
   echo 
"\t\t<p class='day'> $day_num </p>\n";
  }
  
$day_num++;
  
$day_count++;
  
  
//Make sure we start a new row every week
  
if ($day_count 7)
  {
   echo 
"\t</div>\n\t<div class='week'>\n";
   
$day_count 1;
  }

 } 
The date field in the MySQL is the date only (1, 2, 3, etc...). Although, if possible I'd love to get this working so I can use a date formatted as such: MM-DD-YYYY (or any other format compatible with this)

I'd appreciate any help anyone can give. I really need this to work.