001.
<style>table table{
002.
border-spacing: 5px;
003.
border-collapse: collapse;
004.
}
005.
table table td, table table th{
006.
border: 1px solid black;
007.
}
008.
</style>
009.
<table border=
"1"
cellpadding=
"10"
>
010.
<tr>
011.
<td>ปัดทศนิยม 2 ตำแหน่ง</td>
012.
<td>ปัดทศนิย 2 ตำแหน่ง ด้วย PHP_ROUND_HALF_EVEN</td>
013.
<td>ปัดทศนิย 2 ตำแหน่ง ด้วย PHP_ROUND_HALF_ODD</td>
014.
</tr>
015.
<tr>
016.
<td>
017.
<table id=
"document_summary"
class
=
"table table-bordered table-striped"
>
018.
<thead>
019.
<tr>
020.
<th
class
=
"text-center"
>ไตรมาสที่</th>
021.
<th
class
=
"text-right"
>จำนวน (บาท)</th>
022.
<th
class
=
"text-right"
>ร้อยละ</th>
023.
</tr>
024.
</thead>
025.
<tbody id=
"tbody_list"
>
026.
<?php
027.
$data_list_term
=
array
( 1 => 33510723.38, 2 => 18370386.71, 3 => 13147569.72, 4 => 20764823.03 );
028.
$total_sum
=
array_sum
(
$data_list_term
);
029.
$total_term
= 0;
030.
$total_percent
= 0;
031.
$total_loop
=
count
(
$data_list_term
);
032.
$n
=0;
033.
foreach
(
$data_list_term
as
$term
=>
$total
)
034.
{
035.
$n
++;
036.
$percent
=
round
((
$total
* 100) /
$total_sum
, 2);
037.
038.
039.
echo
'<tr>
040.
<td
class
=
"text-center"
>
'.$term.'
</td>
041.
<td
class
=
"text-right"
>
'. number_format($total, 2) .'
</td>
042.
<td
class
=
"text-right"
>
'. number_format($percent, 2) .'
</td>
043.
</tr>';
044.
$total_term
+=
$total
;
045.
$total_percent
+=
$percent
;
046.
}
047.
?>
048.
<tr>
049.
<th
class
=
"text-center"
>รวม</th>
050.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_term
, 2);?></th>
051.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_percent
, 2);?></th>
052.
</tr>
053.
</tbody>
054.
</table>
055.
<br/>
056.
<table id=
"document_summary"
class
=
"table table-bordered table-striped"
>
057.
<thead>
058.
<tr>
059.
<th
class
=
"text-center"
>ไตรมาสที่</th>
060.
<th
class
=
"text-right"
>จำนวน (บาท)</th>
061.
<th
class
=
"text-right"
>ร้อยละ</th>
062.
</tr>
063.
</thead>
064.
<tbody id=
"tbody_list"
>
065.
<?php
066.
$data_list_term
=
array
( 1 => 16384952.27, 2 => 18174658.77, 3 => 16290075.46, 4 => 17268955.96);
067.
$total_sum
=
array_sum
(
$data_list_term
);
068.
$total_term
= 0;
069.
$total_percent
= 0;
070.
$total_loop
=
count
(
$data_list_term
);
071.
$n
=0;
072.
foreach
(
$data_list_term
as
$term
=>
$total
)
073.
{
074.
$n
++;
075.
$percent
=
round
((
$total
* 100) /
$total_sum
, 2);
076.
077.
078.
echo
'<tr>
079.
<td
class
=
"text-center"
>
'.$term.'
</td>
080.
<td
class
=
"text-right"
>
'. number_format($total, 2) .'
</td>
081.
<td
class
=
"text-right"
>
'. number_format($percent, 2) .'
</td>
082.
</tr>';
083.
$total_term
+=
$total
;
084.
$total_percent
+=
$percent
;
085.
}
086.
?>
087.
<tr>
088.
<th
class
=
"text-center"
>รวม</th>
089.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_term
, 2);?></th>
090.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_percent
, 2);?></th>
091.
</tr>
092.
</tbody>
093.
</table>
094.
095.
096.
</td>
097.
<td>
098.
<table id=
"document_summary"
class
=
"table table-bordered table-striped"
>
099.
<thead>
100.
<tr>
101.
<th
class
=
"text-center"
>ไตรมาสที่</th>
102.
<th
class
=
"text-right"
>จำนวน (บาท)</th>
103.
<th
class
=
"text-right"
>ร้อยละ</th>
104.
<th
class
=
"text-right"
>ร้อยละ</th>
105.
</tr>
106.
</thead>
107.
<tbody id=
"tbody_list"
>
108.
<?php
109.
$data_list_term
=
array
( 1 => 33510723.38, 2 => 18370386.71, 3 => 13147569.72, 4 => 20764823.03 );
110.
$total_sum
=
array_sum
(
$data_list_term
);
111.
$total_term
= 0;
112.
$total_percent
= 0;
113.
$total_loop
=
count
(
$data_list_term
);
114.
$n
=0;
115.
$total_percent_4
= 0;
116.
foreach
(
$data_list_term
as
$term
=>
$total
)
117.
{
118.
$n
++;
119.
$percent_4
= (
$total
* 100) /
$total_sum
;
120.
$total_percent_4
+=
$percent_4
;
121.
$percent
=
round
((
$total
* 100) /
$total_sum
, 2, PHP_ROUND_HALF_EVEN);
122.
123.
echo
'<tr>
124.
<td
class
=
"text-center"
>
'.$term.'
</td>
125.
<td
class
=
"text-right"
>
'. number_format($total, 2) .'
</td>
126.
<td
class
=
"text-right"
>
'. number_format($percent_4, 4) .'
</td>
127.
<td
class
=
"text-right"
>
'. number_format($percent, 2) .'
</td>
128.
</tr>';
129.
130.
$total_term
+=
$total
;
131.
$total_percent
+=
$percent
;
132.
}
133.
?>
134.
<tr>
135.
<th
class
=
"text-center"
>รวม</th>
136.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_term
, 2);?></th>
137.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_percent_4
, 2);?></th>
138.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_percent
, 2);?></th>
139.
</tr>
140.
</tbody>
141.
</table>
142.
<br/>
143.
<table id=
"document_summary"
class
=
"table table-bordered table-striped"
>
144.
<thead>
145.
<tr>
146.
<th
class
=
"text-center"
>ไตรมาสที่</th>
147.
<th
class
=
"text-right"
>จำนวน (บาท)</th>
148.
<th
class
=
"text-right"
>ร้อยละ</th>
149.
<th
class
=
"text-right"
>ร้อยละ</th>
150.
</tr>
151.
</thead>
152.
<tbody id=
"tbody_list"
>
153.
<?php
154.
$data_list_term
=
array
( 1 => 16384952.27, 2 => 18174658.77, 3 => 16290075.46, 4 => 17268955.96);
155.
$total_sum
=
array_sum
(
$data_list_term
);
156.
$total_term
= 0;
157.
$total_percent
= 0;
158.
$total_loop
=
count
(
$data_list_term
);
159.
$n
=0;
160.
$total_percent_4
= 0;
161.
foreach
(
$data_list_term
as
$term
=>
$total
)
162.
{
163.
$n
++;
164.
$percent_4
= (
$total
* 100) /
$total_sum
;
165.
$total_percent_4
+=
$percent_4
;
166.
$percent
=
round
((
$total
* 100) /
$total_sum
, 2, PHP_ROUND_HALF_EVEN);
167.
168.
169.
echo
'<tr>
170.
<td
class
=
"text-center"
>
'.$term.'
</td>
171.
<td
class
=
"text-right"
>
'. number_format($total, 2) .'
</td>
172.
<td
class
=
"text-right"
>
'. number_format($percent_4, 4) .'
</td>
173.
<td
class
=
"text-right"
>
'. number_format($percent, 2) .'
</td>
174.
</tr>';
175.
$total_term
+=
$total
;
176.
$total_percent
+=
$percent
;
177.
}
178.
?>
179.
<tr>
180.
<th
class
=
"text-center"
>รวม</th>
181.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_term
, 2);?></th>
182.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_percent_4
, 2);?></th>
183.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_percent
, 2);?></th>
184.
</tr>
185.
</tbody>
186.
</table>
187.
188.
</td>
189.
<td>
190.
<table id=
"document_summary"
class
=
"table table-bordered table-striped"
>
191.
<thead>
192.
<tr>
193.
<th
class
=
"text-center"
>ไตรมาสที่</th>
194.
<th
class
=
"text-right"
>จำนวน (บาท)</th>
195.
<th
class
=
"text-right"
>ร้อยละ</th>
196.
<th
class
=
"text-right"
>ร้อยละ</th>
197.
</tr>
198.
</thead>
199.
<tbody id=
"tbody_list"
>
200.
<?php
201.
$data_list_term
=
array
( 1 => 33510723.38, 2 => 18370386.71, 3 => 13147569.72, 4 => 20764823.03 );
202.
$total_sum
=
array_sum
(
$data_list_term
);
203.
$total_term
= 0;
204.
$total_percent
= 0;
205.
$total_loop
=
count
(
$data_list_term
);
206.
$n
=0;
207.
$total_percent_4
= 0;
208.
foreach
(
$data_list_term
as
$term
=>
$total
)
209.
{
210.
$n
++;
211.
$percent_4
= (
$total
* 100) /
$total_sum
;
212.
$total_percent_4
+=
$percent_4
;
213.
$percent
=
round
((
$total
* 100) /
$total_sum
, 2, PHP_ROUND_HALF_ODD);
214.
215.
echo
'<tr>
216.
<td
class
=
"text-center"
>
'.$term.'
</td>
217.
<td
class
=
"text-right"
>
'. number_format($total, 2) .'
</td>
218.
<td
class
=
"text-right"
>
'. number_format($percent_4, 4) .'
</td>
219.
<td
class
=
"text-right"
>
'. number_format($percent, 2) .'
</td>
220.
</tr>';
221.
222.
$total_term
+=
$total
;
223.
$total_percent
+=
$percent
;
224.
}
225.
?>
226.
<tr>
227.
<th
class
=
"text-center"
>รวม</th>
228.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_term
, 2);?></th>
229.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_percent_4
, 2);?></th>
230.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_percent
, 2);?></th>
231.
</tr>
232.
</tbody>
233.
</table>
234.
<br/>
235.
<table id=
"document_summary"
class
=
"table table-bordered table-striped"
>
236.
<thead>
237.
<tr>
238.
<th
class
=
"text-center"
>ไตรมาสที่</th>
239.
<th
class
=
"text-right"
>จำนวน (บาท)</th>
240.
<th
class
=
"text-right"
>ร้อยละ</th>
241.
<th
class
=
"text-right"
>ร้อยละ</th>
242.
</tr>
243.
</thead>
244.
<tbody id=
"tbody_list"
>
245.
<?php
246.
$data_list_term
=
array
( 1 => 16384952.27, 2 => 18174658.77, 3 => 16290075.46, 4 => 17268955.96);
247.
$total_sum
=
array_sum
(
$data_list_term
);
248.
$total_term
= 0;
249.
$total_percent
= 0;
250.
$total_loop
=
count
(
$data_list_term
);
251.
$n
=0;
252.
$total_percent_4
= 0;
253.
foreach
(
$data_list_term
as
$term
=>
$total
)
254.
{
255.
$n
++;
256.
$percent_4
= (
$total
* 100) /
$total_sum
;
257.
$total_percent_4
+=
$percent_4
;
258.
$percent
=
round
((
$total
* 100) /
$total_sum
, 2, PHP_ROUND_HALF_ODD);
259.
260.
261.
echo
'<tr>
262.
<td
class
=
"text-center"
>
'.$term.'
</td>
263.
<td
class
=
"text-right"
>
'. number_format($total, 2) .'
</td>
264.
<td
class
=
"text-right"
>
'. number_format($percent_4, 4) .'
</td>
265.
<td
class
=
"text-right"
>
'. number_format($percent, 2) .'
</td>
266.
</tr>';
267.
$total_term
+=
$total
;
268.
$total_percent
+=
$percent
;
269.
}
270.
?>
271.
<tr>
272.
<th
class
=
"text-center"
>รวม</th>
273.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_term
, 2);?></th>
274.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_percent_4
, 2);?></th>
275.
<th
class
=
"text-right"
><?php
echo
number_format(
$total_percent
, 2);?></th>
276.
</tr>
277.
</tbody>
278.
</table>
279.
280.
</td>
281.
</tr>
282.
</table>
283.
284.
</table>