Log in

View Full Version : PHP Calendar



ReadyToLearn
01-29-2008, 04:05 PM
Greetings everyone!

I found a script for a calender while browsing through this forum (specifically, here (http://www.dynamicdrive.com/forums/showthread.php?p=127499#post127499)).

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.).


// Get Event Dates
$query = "SELECT * FROM kb_events";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_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 (http://www.dynamicdrive.com/dynamicindex7/jasoncalendar.htm))

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