I have a table generated with a loop with column headers mon trough to fri and time array with 30min intervals for 24hr I have just shorten the example code:
$times = array(00:00, 00:30, 01:00, 01:30);
$skip = array();
$row = 1;
<table>
<tr>
<td>Time</td><td>Mon</td><td>tue</td>
<tr>
foreach($times AS $val){
$stmt = $mysqli->prepare("
SELECT `show`,`time_start`,`time_stop`,`show_day`
FROM `db_shows` WHERE `time_start`='$val'
");
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($myrow[show],$myrow[time_start],$myrow[time_stop],$myrow[show_day]);
$stmt->fetch();
// GET THE ROWSPAN
$a = new DateTime($myrow[time_start]);
$b = new DateTime($myrow[time_stop]);
$interval = $a->diff($b);
$res = $interval->format('%h');
$res *= 2;
$res += 1;
// ARRY FOR ROWS TO SKIP TD
code in second part
// APPLAY DISPLAY NONE IF NEEDED
code in second part
// BUILD COLUMNS
switch($myrow[show_day]){
case "":$tds = "<td> </td><td> </td>"; break;
case "mon":$tds = "<td rowspan="$res" style="$mon">$myrow[show]</td><td> </td>"; break;
case "tue":$tds = "<td> </td><td rowspan="$res" style="$tue">$myrow[show]</td>"; break;
}
<tr>
<td>$val</td>$tds
</tr>
$row++;
}
</table>
Now my code works fine generating the the table with the rowspan, but I know I have to remove the necessary td's in the next rows depending on how many rows my rowspan ($res) contain. This is probably the part I'm falling out of the bus :) What I'm trying to achieve here is to get the row number and 'day td' to hide in the rows that follow
// ARRY FOR ROWS TO SKIP TD
if($res >=2){
$rowCount = $res -1;
$rowSkip = $row;
for($i=1;$i <= $rowCount; $i++){
$rowSkip++;
$skip[$rowSkip] = $myrow[show_day];
}
}
// LOOK IF ROW HAVE VALUE
foreach($skip AS $key2 => $val2){
if($row == "$key2" && $myrow[show_day]="$val2"){
$$val2 = "display:none";
}
}
I'm not even sure if I'm approaching the whole concept on the right matter, any help will be greatly appreciated. Thank You!!
In the end of the day my table should look like this: