[![enter image description here](https://i.stack.imgur.com/kpMmD.png)](https://i.stack.imgur.com/kpMmD.png)im trying to create a class scheduling table, i want to plot the schedules from may result set to create a tabular representation. 

i have a fixed header or days MONDAY-SATURDAY on top and 7:00 AM-9:00 pm on the left side of the table.

```
$scheduledet = json_decode(json_encode($data['scheduledet']), true);
print_r($scheduledet);
$week_days = array('M','T','W','TH','F','S');
$range=range(strtotime("07:00"),strtotime("22:00"),30*60);
$rowspan = 0;
$rangetime = [];
foreach($range as $time){
    $rangetime[] = date("H:i",$time);
}
foreach($week_days as $key => $wday){
    $schedfortheday = array_filter($scheduledet, function ($item) use ($wday) {
        if ($item['day'] == $wday) {
            return true;
        }
        return false;
    });

    foreach ($schedfortheday as $key => $value) {
        $rowspan = 0;
        $count = 1;
        foreach ($rangetime as $k => $v) {

            if(strtotime($v) >= strtotime($value['fromtime']) && strtotime($v) <= strtotime($value['totime'])){
                $rowspan ++;
            }
        }
    }
}

<table border="2" style= "width:100%; margin: 0 auto;" cellpadding="0" cellspacing="0">
    <tr>
        <th scope="col">&nbsp;</th>
        <th scope="col">Monday</th>
        <th scope="col">Tuesday</th>
        <th scope="col">Wednesday</th>
        <th scope="col">Thursday</th>
        <th scope="col">Friday</th>
        <th scope="col">Saturday</th>
    </tr>
        <tr>
        <td>7:00 AM</td>
    </tr>
    <tr>
        <td>7:30 AM</td>
    </tr>
    <tr>
        <td>8:00 AM</td>
    </tr>
    <tr>
        <td>8:30 AM</td>
    </tr>
    <tr>
        <td>9:00 AM</td>
    </tr>
    <tr>
        <td>9:30 AM</td>
    </tr>
    <tr>
        <td>10:00 AM</td>
    </tr>
    <tr>
        <td>10:30 AM</td>
    </tr>
    <tr>
        <td>11:00 AM</td>
    </tr>
    <tr>
        <td>11:30 AM</td>
    </tr>
    <tr>
        <td>12:00 PM</td>
    </tr>
    <tr>
        <td>12:30 PM</td>
    </tr>
    <tr>
        <td>1:00 PM</td>
    </tr>
    <tr>
        <td>1:30 PM</td>
    </tr>
    <tr>
        <td>2:00 PM</td>
    </tr>
    <tr>
        <td>2:30 PM</td>
    </tr>
    <tr>
        <td>3:00 PM</td>
    </tr>
    <tr>
        <td>3:30 PM</td>
    </tr>
    <tr>
        <td>4:00 PM</td>
    </tr>
    <tr>
        <td>4:30 PM</td>
    </tr>
    <tr>
        <td>5:00 PM</td>
    </tr>
    <tr>
        <td>5:30 PM</td>
    </tr>
    <tr>
        <td>6:00 PM</td>
    </tr>
    <tr>
        <td>6:30 PM</td>
    </tr>
    <tr>
        <td>7:00 PM</td>
    </tr>
    <tr>
        <td>7:30 PM</td>
    </tr>
    <tr>
        <td>8:00 PM</td>
    </tr>
    <tr>
        <td>8:30 PM</td>
    </tr>
    <tr>
        <td>9:00 PM</td>
    </tr>

</table>
Array(Array
    (
        'id' => '4545',
        'classid' => '1842',
        'fromtime' => '09:30:00',
        'totime' => '11:30:00',
        'day' => 'M',
        'room' => 'B01',
        'code' => 'BCS 1',
        'subdesc' => 'IT APPLICATION TOOLS IN BUSINESS',
        'units' => '3'
    ), Array(
        'id' => '4460',
        'classid' => '1596',
        'fromtime' => '10:30:00',
        'totime' => '11:30:00',
        'day' => 'M',
        'room' => '122A',
        'code' => 'PS 101',
        'subdesc' => 'FUNDAMENTALS OF POLITICAL SCIENCE',
        'units' => '3'
    ),Array
    (
        'id' => '4463',
        'classid' => '1598',
        'fromtime' => '13:00:00',
        'totime' => '14:00:00',
        'day' => 'M',
        'room' => 'TBA',
        'code' => 'PSOE 1',
        'subdesc' => 'PHILIPPINE POLITICAL THOUGHT',
        'units' => '3'
    ),Array(
        'id' => '3881',
        'classid' => '1597',
        'fromtime' => '14:00:00',
        'totime' => '15:00:00',
        'day' => 'M',
        'room' => 'TBA',
        'code' => 'PS 102',
        'subdesc' => 'INTRODUCTION TO PHILIPPINE POLITICS AND GOVERNANCE',
        'units' => '3'
    ),Array(
        'id' => '4540',
        'classid' => '1609',
        'fromtime' => '16:00:00',
        'totime' => '17:00:00',
        'day' => 'M',
        'room' => '205',
        'code' => 'CFE 3',
        'subdesc' => 'CATHOLIC FOUNDATION OF MISSION',
        'units' => '3'
    ))

```

this is my schedule array from my result set, if there are conflict schedule it will ovelap each rowspan and display the information of conflict schedule. i cannot plot the result set in the table. any help will be appreciated thanks in advance

it allows schedule overlap and it will still be displayed in the table as merged table cells. the image with red cell represents 2 subjects are in conflict and with same schedule

[![enter image description here](https://i.stack.imgur.com/jUyN8.png)](https://i.stack.imgur.com/jUyN8.png)