View Full Version : show days(dates) on screen

05-23-2011, 02:45 PM
the following function brings back all events in my google calendar between 2 dates (which I have set manually) 2 weeks from today

I would like to write out each day even if it does have an event

at the moment it only writes out a line with an event

function outputCalendarByDateRange($client, $startDate='2007-05-01',
$gdataCal = new Zend_Gdata_Calendar($client);
$query = $gdataCal->newEventQuery();
$eventFeed = $gdataCal->getCalendarEventFeed($query);
echo "<ul>\n";
foreach ($eventFeed as $event) {
echo "\t<li>" . $event->title->text . " (" . $event->id->text . ")\n";
echo "\t\t<ul>\n";
foreach ($event->when as $when) {
echo "\t\t\t<li>Starts: " . $when->startTime . "</li>\n";
echo "\t\t</ul>\n";
echo "\t</li>\n";
echo "</ul>\n";

echo outputCalendarByDateRange($client, '2011-05-23', '2011-06-06');

05-23-2011, 08:38 PM
Wait... do you mean you want to write the date even if it DOESN'T have an event? Basically display a 2 week itinerary, showing the events on each date (showing nothing if there are no events)?

If so, then you need to first sort the events' data into arrays, loop through the days, and check if the array contains any events on that day, displaying each day as you go. You'd probably want to use something like creating 2 arrays: one with all the data (ie, store each event object as an element in an array), and one array that contains the data's key in array 1 associated to the date of the event. So then you can use array_keys (http://www.php.net/manual/en/function.array-keys.php) to search array 2 for the dates, getting back the appropriate keys pointing to the events in array 1, looping through those to get all the events on that day.