I have a table and i want to merge the value of Total column for each month.
This is my code :
<table border="1" cellpadding="3" cellspacing="0" class="table_content">
<tr>
<td width="38" rowspan="2">NO.</td>
<td rowspan="2">PILOT ON BOARD</td>
<td colspan="2">PILOT ON BOARD</td>
<td rowspan="2">PILOT WAITING TIME</td>
<td rowspan="2">TOTAL</td>
<td rowspan="2">BERTHING</td>
</tr>
<tr>
<td width="100">DATE </td>
<td width="100">TIME</td>
</tr>
<?php
$no=0;
$dataFromTable=json_decode('[{"PilotWaitingTime":"0.2","PilotOnBoardDate":"2013-01-01","PilotOnBoardTime":"17:40:00","PilotOnBoard":"2013-01-01 17:40:00","Berthing":"2013-01-01 20:25:00","rata2PilotWaitingTime":"9.067"},{"PilotWaitingTime":"19.2","PilotOnBoardDate":"2013-01-03","PilotOnBoardTime":"12:15:00","PilotOnBoard":"2013-01-03 12:15:00","Berthing":"2013-01-03 15:10:00","rata2PilotWaitingTime":"9.067"},{"PilotWaitingTime":"7.8","PilotOnBoardDate":"2013-01-03","PilotOnBoardTime":"14:45:00","PilotOnBoard":"2013-01-03 14:45:00","Berthing":"2013-01-03 17:05:00","rata2PilotWaitingTime":"9.067"},{"PilotWaitingTime":"6.4","PilotOnBoardDate":"2013-02-04","PilotOnBoardTime":"18:25:00","PilotOnBoard":"2013-02-04 18:25:00","Berthing":"2013-02-04 20:25:00","rata2PilotWaitingTime":"6.000"},{"PilotWaitingTime":"5.6","PilotOnBoardDate":"2013-02-06","PilotOnBoardTime":"05:40:00","PilotOnBoard":"2013-02-06 05:40:00","Berthing":"2013-02-06 08:30:00","rata2PilotWaitingTime":"6.000"},{"PilotWaitingTime":"26","PilotOnBoardDate":"2013-03-04","PilotOnBoardTime":"13:00:00","PilotOnBoard":"2013-03-04 13:00:00","Berthing":"2013-02-04 20:25:00","rata2PilotWaitingTime":"26.000"}]',true);
foreach( $dataFromTable as $results ){
?>
<tr>
<td width="38" style="text-align:right"><?php echo $no+=1; ?></td>
<td width="150"><?php echo $results['PilotOnBoard']; ?></td>
<td width="100"><?php echo $results['PilotOnBoardDate']; ?> </td>
<td width="100"><?php echo $results['PilotOnBoardTime']; ?></td>
<td style="text-align:right"><?php echo $results['PilotWaitingTime']; ?></td>
<td style="text-align:right"><?php echo $results['rata2PilotWaitingTime']; ?></td>
<td style="text-align:right"><?php echo $results['Berthing']; ?></td>
</tr>
<?php }; ?>
</table>
This is the result:
PilotOnBoard PilotOnBoardDate PilotOnBoardTime PilotWaitingTime Total Berthing
2013-01-01 17:40:00 2013-01-01 17:40:00 0.2 9.067 2013-01-01 20:25:00
2013-01-03 12:15:00 2013-01-03 12:15:00 19.2 9.067 2013-01-03 15:10:00
2013-01-03 14:45:00 2013-01-03 14:45:00 7.8 9.067 2013-01-03 17:05:00
2013-02-04 18:25:00 2013-02-04 18:25:00 6.4 6.000 2013-02-04 20:25:00
2013-02-06 05:40:00 2013-02-06 05:40:00 5.6 6.000 2013-02-06 08:30:00
2013-03-04 13:00:00 2013-03-04 13:00:00 26 26.000 2013-02-04 20:25:00
I'm trying to merge the total column for each month. January = 9.067, February 6.000 and March 26.000.
This is the result i'm trying to make:
PilotOnBoard PilotOnBoardDate PilotOnBoardTime PilotWaitingTime Total Berthing
2013-01-01 17:40:00 2013-01-01 17:40:00 0.2 | | 2013-01-01 20:25:00
2013-01-03 12:15:00 2013-01-03 12:15:00 19.2 | 9.067| 2013-01-03 15:10:00
2013-01-03 14:45:00 2013-01-03 14:45:00 7.8 |______| 2013-01-03 17:05:00
2013-02-04 18:25:00 2013-02-04 18:25:00 6.4 | 6.000| 2013-02-04 20:25:00
2013-02-06 05:40:00 2013-02-06 05:40:00 5.6 |______| 2013-02-06 08:30:00
2013-03-04 13:00:00 2013-03-04 13:00:00 26 |26.000| 2013-02-04 20:25:00
Thank you for your help