PHP - Grouping Duration based events / rows into single html blocks -
so i've got bunch of 'events' in table in have start , end column (both datetime). i'm fetching every event single day , somehow need group them can displayed single html block.
for example...
row #1: has duration of 30 minutes, starts @ 09:00:00 , ends @ 09:30:00 row #2: has duration of 30 minutes, starts @ 09:30:00 , ends @ 10:00:00 row #3: has duration of 90 minutes, starts @ 12:00:00 , ends @ 13:30:00
what best way know need 2 html blocks... 1 div has 60px height (for rows 1 , 2), , because there's break between 10:00:00 , 12:00:00 have div 90px height (row 3).
can done mysql somehow? or have php loop check empty spaces of time in order know when should close div , begin new one?
any beneficial.
this more of logic question code question.
you can in mysql. 1 way using correlated subquery determine when "event periods" begin. new event period begins when not overlap others. use information assign "event period id" each event.
such query perform reasonably right indexes.
you in php. biased toward putting such logic database rather in application code.
Comments
Post a Comment