01.
<?php
02.
03.
$nowYear
=
date
(
'Y'
);
04.
$startYear
= 2549-543;
05.
06.
for
(
$year
=
$nowYear
;
$year
>=
$startYear
;
$year
--)
07.
{
08.
echo
"<tr>"
;
09.
echo
"<td><b>"
.(
$year
+543).
"</b></td>"
;
10.
11.
for
(
$month
=1;
$month
<=12;
$month
++)
12.
{
13.
$dmonth
=cal_days_in_month(CAL_GREGORIAN,
$month
,
$year
);
14.
15.
16.
$strSQL
=
"SELECT COUNT (VN) as total FROM DNStatistica.dbo.ST_MASTER WHERE VisitDate BETWEEN '"
.
$nowYear
.
"-"
.
$month
.
"-1' AND '"
.
$nowYear
.
"-"
.
$month
.
"-"
.
$dmonth
.
"' AND Cxl='0'"
;
17.
18.
$objExec
= odbc_exec(
$conn
,
$strSQL
)
or
die
(
"Error SQL ["
.
$strSQL
.
"]"
);
19.
while
(
$objResult
= odbc_fetch_object(
$objExec
))
20.
{
21.
$net
=
$objResult
->total*12;
22.
$avg
=
$net
/365;
23.
echo
"<td>"
.(number_format(
$objResult
->total)).
"<br></td>"
;
24.
}
25.
26.
}
27.
echo
"<td>"
.(number_format(
$net
)).
"</td>"
;
28.
echo
"<td>"
.(number_format(
$avg
, 2)).
"</td>"
;
29.
30.
$nowYear
--;
31.
32.
echo
"</tr>"
;
33.
}
34.
35.
?>