On Oct 20, 2010, at 12:47 PM, Tommy Pham wrote:

>> -----Original Message-----
>> From: Floyd Resler [mailto:fres...@adex-intl.com]
>> Sent: Wednesday, October 20, 2010 9:17 AM
>> To: PHP
>> Subject: [PHP] Calendar Logic Help
>> 
>> I'm having problems getting my head around some login for a calendar.
>> Specifically, the problem is drawing weekly views for events that span
>> multiple days.  I've gotten it so that if an event starts in the week
> being
>> viewed, the days draw correctly for the remainder of the week.  However,
> if
>> the event goes into the next week, its start date is now outside my date
>> range and so it doesn't display.  I know how to say the logic, I'm not
> sure
>> how to write it!  The logic would be: if any date between the start and
> end
>> dates of the event are within the week being displayed, show the event.
> I'd
>> like to put the logic into my MySQL query so I don't have to get all
> events
>> from the calendar to see what should be displayed.  Any ideas?
>> 
>> Thanks!
>> Floyd
>> 
> 
> It's hard to give you hints without knowing some actual PHP code and SQL
> table columns but here goes:
> 
> PHP logic: $event['startDate'] <= $weekEnd && $event['endDate'] >=
> $weekStart
> 
> Query logic: SELECT * FROM event_table WHERE `start_date` <= @weekEnd and
> `end_date` >= @weekStart
> 
> week* is the week being viewed.  You may have to use the DateTime class or
> one of the date_* functions to compare the date for the PHP logic.  @ is the
> input query parameter.  This assumes you have table columns for the event:
> start_date & end_date.  Adjust the query as needed for multi table joins.
> 
> Regards,
> Tommy
> 

That worked perfect! 

Thanks!
Floyd


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to