echo $i?> |
=$row["Acc_type"]?>
|
execQuery($query1);
$countnum = $dbObj->_numrows;
$dbObj->freeresult($result1);
echo number_format( $countnum );
?> |
$now = date('Y-m-d');
$yearthai = explode( "-", $now );
$day = intval( $yearthai[2]);
$month = intval( $yearthai[1] );
$year = intval( $yearthai[0] )+543;
$sday1 = $year."-".$month."-".$day;
$query = " SELECT * FROM accessories_tb at, accessories_type_tb att WHERE at.Dura='Y' and at.Acc_type_code = att.Acc_type_code and at.Acc_type_code !='0' and at.Acc_type_code='$row[Acc_type_code]' AND at.Date_finish > '".$sday1."' ";
$result11 = $dbObj->execQuery($query);
$count = $dbObj->_numrows;
echo $count;
?> |
if($count) {
$sum = 0;
while($rs11 = $dbObj->fetchArray($result11)) {
for($k=0;$k<=$count;$k++) {
$Price = $rs11["Price"];
$Day = $rs11["Day"];
$sday = $rs11["Date_buy"];
$yearthai1 = explode( "-", $sday );
$day1 = intval( $yearthai1[2] );
$month1 = intval( $yearthai1[1] );
$year1 = intval( $yearthai1[0] );
$result_1 = mktime(0, 0, 0, $month, $day, $year); //นำวันเดือนปี 1 มาแปลงเป็นรูปแบบ Unix timestamp
$result_2 = mktime(0, 0, 0, $month1, $day1, $year1); //นำวันเดือนปี 2 มาแปลงเป็นรูปแบบ Unix timestamp
$result_date = $result_1 - $result_2; //นำวันที่ 1 - วันที่ 2
$Day_buy = $result_date / (60 * 60 * 24); //แปลงค่าเวลารูปแบบ Unix timestamp ให้เป็นจำนวนวัน
$Price_day = $Price/$Day;
$Price_buy = $Day_buy*number_format($Price_day,2, '.', ',');
$num = $num[$k] + $Price_buy;
}
$sum += $num;
}
echo number_format($sum,2, '.', ',');
}
else {
echo "0";
}
?> |
$query12 = " SELECT * FROM accessories_tb at, accessories_type_tb att WHERE at.Dura='Y' and at.Acc_type_code = att.Acc_type_code and at.Acc_type_code !='0' and at.Acc_type_code='$row[Acc_type_code]' AND at.Date_finish > '".$sday1."' ";
$result12 = $dbObj->execQuery($query12);
if($count) {
$Total = 0;
while($rs12 = $dbObj->fetchArray($result12)) {
$Total += $rs12["Price"];
}
$sum2 = $Total-$sum;
echo number_format($sum2,2, '.', ',');
}
else {
echo "0";
}
?> |
freeresult($result);
?>