I'm working on an event calendar.
The script searches a database for events, then adds a selector tag to the dates which have them.
I got it to work to display ALL events (regardless of the month).
I'm trying to limit the results to the current month, but no luck.
Hopefully someone can help me out here...
$dates[$curr_month] display the correct info but I don't know how to search through the values in that.PHP Code://This puts the day, month, and year in seperate variables
$day = date('d', $date) ;
$month = date('m', $date) ;
$curr_month = date('n', $date) ;
$year = date('Y', $date) ;
$sql = mysql_query ("SELECT *, DATE_FORMAT(date, '%e') as date, DATE_FORMAT(date, '%c') as month from events" );
while($row = mysql_fetch_array($sql, MYSQL_ASSOC))
{
$months = $row['month'];
$date = $row['date'];
$dates = array($months => $date);
}
I've been using this to get ALL events (again, irrespective of the month)
Any thoughts?PHP Code://sets the first day of the month to 1
$day_num = 1;
//count up the days, untill we've done all of them in the month
while ( $day_num <= $days_in_month )
{
if (in_array($day_num, $dates)) {
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;
}
}



Reply With Quote
Bookmarks