Jump to content

Table with mix display data(vertical & horizontal)


Nazirul_Fitri

Recommended Posts

post-202187-0-63125800-1473317819_thumb.pngpost-202187-0-15296300-1473318502_thumb.pngHi there, 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 verticallly 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 try for a weeks and got stuck. Please help. :(

 

below is my code:

<html>
<head>
<meta charset="utf-8">
<title><?php echo $report_title ?></title>
<link href="wilma2/css/buttons.dataTables.min.css" rel="stylesheet" type="text/css">
<link href="wilma2/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css">
<link href="css/custom2.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap.css" rel="stylesheet" type="text/css">
</head>
<body>
	<?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> &nbsp&nbsp'.$kmn_branch.'</td>
					'.$kmn_kutip.'
					<td align="right">'.number_format ($jum_kutip,2).'<br>'.number_format ($jum_amt,2).'</td>
				</tr>
			</tbody>
		</table>
	';
	?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.