Re: calendar Q

From: Date: Fri, 11 Aug 2006 05:23:18 +0000
Subject: Re: calendar Q
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-240533@lists.php.net to get a copy of this message
Ok. Thanks. One more question. I have dates as a datetime in DB. Like 2006-08-11 08:20:00 and I'm playing only with date part in the calendar 2006-08-11. So how to compare this date to the datetime info in DB? Do I need to use DATE_FORMAT or someting like this in the query? Thanks -Will ""Richard Lynch"" <ceo@l-i-e.com> kirjoitti viestissä:2821.67.108.68.40.1155241480.squirrel@www.l-i-e.com... > On Thu, August 10, 2006 12:14 pm, William Stokes wrote: >> I have a calendar script that displays a simple mini calendar view one >> month >> at a time. User can click any date and the calendar opens another page >> that >> displays that date's events. I would like to highlight to the mini >> calendar >> view dates that have an event in database. So what would be a simple >> way to >> check for events while the selected months days are printed to screen? > > Depending on the number of records, the PHP<->MySQL connection speed, > and the indexes or lack thereof on your date column... > > 1. You could do a query for each date like: > select count(*) from events where whatdate = '$date' > > 2. You could pre-fill an array with dates that have an event: > select whatdate from events > where whatdate >= '$month/1/$year' > and whatdate < '{$month+1}/1/$year' /*might need something better here*/ > group by whatdate > order by whatdate > while (list($whatdate) = mysql_fetch_row($result)){ > $event_date[$whatdate] = true; > } > Then, while filling out the calendar, just check: > if (isset($event_date[$date])){ > //color it as having events > } > > -- > Like Music? > http://l-i-e.com/artists.htm

« previous php.general (#240533) next »