Can anyone help me on this one. I need to produce table like picture Result.png, but as you can see the first row I need to display it vertically but the second column I need to display it as horizontal. Plus, the ‘Jumlah’ at the end column is the total of each row and I need to put another total below all the row to calculate the total by column. I have tried for a week and got stuck. Please help.
below is my code:
<?php
$total_pkutip2 = 0;
$total_amt2 = 0;
$jum_kutip = 0;
$jum_amt = 0;
while (($row = oci_fetch_assoc($stid)) != false) {
$kmn_produk = $row['PRODUK'];
$kmn_state = $row['STATE'];
$kmn_branch = $row['BRANCHNAME'];
$kmn_kutip .= '<td align="right">'.number_format ($row['PKUTIP'],2).'<br>'.number_format ($row['AMOUNT'],2).'</td>';
$kmn_mth .= '<td>'.$row['MTH'].'</td>';
$jum_kutip += $row['PKUTIP'];
$jum_amt += $row['AMOUNT'];
//$jum_kutip[$kmn_mth] = $jum_kutip[$kmn_mth] + $kmn_kutip; //ni equivalent line atas ni.
$total_pkutip2 = $total_pkutip2 + $kmn_kutip;
$total_amt2 = $total_amt2 + $kmn_amt;
}
echo '
<h3>LAPORAN KUTIPAN MENGIKUT NEGERI DAN KAWASAN BAGI TAHUN '.$getyear.' </h3>
<h4>PRODUK : '.$kmn_produk.'</h4>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="table1" class="display">
<thead>
<tr>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col" align="center">NEGERI | KAWASAN<br></th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">JAN '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">FEB '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">MAC '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">APR '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">MEI '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">JUN '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">JUL '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">AUG '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">SEP '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">OKT '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">NOV '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">DEC '.$getyear.'<br>PATUT KUTIP<br>KUTIPAN</th>
<th style="text-align:center" bgcolor="#CCCCCC" scope="col">JUMLAH</th>
</tr>
</thead>
<tbody>
<tr>
<td><b>'.$kmn_state.'</b><br>   '.$kmn_branch.'</td>
'.$kmn_kutip.'
<td align="right">'.number_format ($jum_kutip,2).'<br>'.number_format ($jum_amt,2).'</td>
</tr>
</tbody>
</table>
';
?>
data :
result: