Trying to generate a week-timeline with PHP
<p>I'm coding some kind of schedule and get stuck itterating trough the the dates.</p>

<p>I have a timeline generated for 5 work-days starting at 6:00h till 18:30h this is no problem. 
I have a table with users and a table with dates. The users can have multiple tasks during the week.</p>

<p>This is the array:</p>

<pre><code>Array
(
    [0] =&gt; Array
        (
            [dateStart] =&gt; 2011-09-14 13:00:00
            [dateEnd] =&gt; 2011-09-15 11:00:00
            [eventType] =&gt; 1
            [data] =&gt; test
            [taskDescription] =&gt; Vakantieverlof
            [taskColor] =&gt; ff6600
        )

    [1] =&gt; Array
        (
            [dateStart] =&gt; 2011-09-14 15:00:00
            [dateEnd] =&gt; 2011-09-14 18:00:00
            [eventType] =&gt; 3
            [data] =&gt; 
            [taskDescription] =&gt; ADV
            [taskColor] =&gt; 336600
        )

    [2] =&gt; Array
        (
            [dateStart] =&gt; 2011-09-15 16:00:00
            [dateEnd] =&gt; 2011-09-16 10:00:00
            [eventType] =&gt; 2
            [data] =&gt; 
            [taskDescription] =&gt; Ziek
            [taskColor] =&gt; ff0000
        )
)
</code></pre>

<p>And this is the loop trough the array:</p>

<pre><code>$dat=0;
while($dat&lt;count($row-&gt;dates))
{
    $color = "cccccc";

    if(!empty($row-&gt;dates[$dat]['taskColor'])) {
        $color = $row-&gt;dates[$dat]['taskColor'];
        $desc = $row-&gt;dates[$dat]['taskDescription'];
    } else {
        $color = "cccccc";
    }
    $datNext = $dat+1;
    if($datNext &gt;= count($row-&gt;dates)) $datNext = $dat;
    if($row-&gt;dates[$datNext]['dateStart'] &gt;= $hourCons AND $dat &gt;= count($row-&gt;dates))
    {
        $dat++;

    } else {
        if( $row-&gt;dates[$dat]['dateStart'] &lt; $hourConsEnd AND $row-&gt;dates[$dat]['dateEnd'] &gt; $hourCons )
        {
            $wpcal .= "&lt;div class=\"fullCell\" style=\"".$transparent." background-color: #".$color.";\"&gt;&lt;/div&gt;";

        } else {
            $wpcal .= "&lt;div class=\"emptyCell\" style=\"\"&gt;&lt;/div&gt;";


        }
    }
    $dat++;

}
</code></pre>

<p>Now I get 3 timelines representing each planned task. like this:</p>

<p><a href="http://www.websites-uit-limburg.nl/timeline-screenshot.png" rel="nofollow">Screenshot</a></p>

<p>But I want 1 timeline containing each of these tasks... the green task in this case may overlap the orange.</p>

<p>Please help I'm strungling with it for a couple of days now...</p>
