|
 |
|
php คำสั่งSQL+โค๊ต ครับช่วยดูให้ทีว่ามันผิดตรงไหนครับ คือจะคิดคำนวณรายได้จากการขายยอดขายรายปี |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
session_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<title>สรุปการขายประจำปี</title>
</head>
<body>
<?
include "dbconn.inc.php";
$key=$_REQUEST['years'];
$yearnow=date("Y") + 543;
?>
<table width="76%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td colspan="4" align="center"><h1>สรุปการขายประจำปี
<? if ($key<>"") {
echo $key;
} else {
echo $yearnow;
}
?>
</h1><br>
<FORM name=searchYear action=showsell_year.php method="post"> ค้นหายอดขายตาม..
<INPUT size=25 name=years>
<INPUT type=submit value="ค้นหา" name=BtnSearch>
</FORM>
</td>
</tr>
<tr bgcolor="#FF9900">
<td width="25%" height="30" align="center"><b>เดือนที่ขาย</b></td>
<td width="25%" height="30" align="center"><b>จำนวนรหัสการขาย</b></td>
<td width="25%" height="30" align="center"><b>จำนวนพระเครื่อง</b></td>
<td width="25%" height="30" align="center"><b>จำนวนเงิน</b></td>
</tr>
<?
if ($_REQUEST['years']=="") {
$result_sell=mysql_query(" SELECT COUNT(tb_order.od_id) AS COUNTSELL, SUM( tb_orderview
.odv_amount) AS SUMTOTAL, tb_order.od_date FROM tb_order , tb_orderview WHERE (tb_order .od_status) and (tb_order .od_date)='$yearnow' GROUP BY substr( tb_order.od_date) ORDER BY tb_order.od_date DESC");
} else {
$result_sell=mysql_query("SELECT COUNT(tb_order.od_id) AS COUNTSELL, SUM( tb_orderview
.odv_amount) AS SUMTOTAL, tb_order.od_date FROM tb_order , tb_orderview WHERE (tb_order .od_status ) and (tb_order .od_date)='$key' GROUP BY substr( tb_order.od_date) ORDER BY tb_order.od_date DESC");
}
$totalrecord=mysql_num_rows($result_sell);
while ($dbarr_sell = mysql_fetch_array($result_sell)) {
$stotal=$stotal+$dbarr_sell['COUNTSELL'];
$mtotal=$mtotal+$dbarr_sell['SUMTOTAL'];
$noofmonth=substr($dbarr_sell[od_date]);
if ($noofmonth=="01") {
$nmonth="มกราคม";
} elseif ($noofmonth=="02") {
$nmonth="กุมภาพันธ์";
} elseif ($noofmonth=="03") {
$nmonth="มีนาคม";
} elseif ($noofmonth=="04") {
$nmonth="เมษายนพ";
} elseif ($noofmonth=="05") {
$nmonth="พฤษภาคม";
} elseif ($noofmonth=="06") {
$nmonth="มิถุนายน";
} elseif ($noofmonth=="07") {
$nmonth="กรกฎาคม";
} elseif ($noofmonth=="08") {
$nmonth="สิงหาคม";
} elseif ($noofmonth=="09") {
$nmonth="กันยายน";
} elseif ($noofmonth=="10") {
$nmonth="ตุลาคม";
} elseif ($noofmonth=="11") {
$nmonth="พฤศจิกายน";
} elseif ($noofmonth=="12") {
$nmonth="ธันวาคม";
}
$monthyear=substr($dbarr_sell[od_date]);
?>
<tr>
<td align="left"><?=$nmonth;?></td>
<td align="center"><?=$dbarr_sell['COUNTSELL'] ?></td>
<td align="center">
<?
$result_sell2=mysql_query("SELECT SUM( tb_orderview.odv_amount ) AS SUMQTY FROM tb_order, tb_orderview WHERE (tb_order.od_id = tb_orderview.od_id) AND substr(tb_order.od_status ) AND (tb_order.od_date)='$monthyear'");
$dbarr_sell2 = mysql_fetch_array($result_sell2);
$ctotal=$ctotal+$dbarr_sell2['SUMQTY'];
echo $dbarr_sell2['SUMQTY'];
?>
</td>
<td align="right"><?=number_format($dbarr_sell['SUMTOTAL'],2,'.',','); ?></td>
</tr>
<?
?>
<tr bgcolor="#FFFF99">
<td align="right"><b>รวมทั้งหมด</b></td>
<td align="center"><?=$stotal;?></td>
<td align="center"><?=$ctotal;?></td>
<td align="right"><b><?=number_format($mtotal,2,'.',','); ?></b></td>
</tr>
</table>
</body>
</html>
อันนี้คือที่มันบอกERROR
Parse error: syntax error, unexpected $end in C:\AppServ\www\ecomm\showsell_year.php on line 112
Tag : PHP, MySQL, HTML/CSS, JavaScript, WebService

|
|
 |
 |
 |
 |
Date :
2012-04-08 03:21:22 |
By :
deksp |
View :
989 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ได้ปิด While ?
|
 |
 |
 |
 |
Date :
2012-04-08 04:11:16 |
By :
50121680 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น่าจะหมายถึง } ปิดไม่ครบครับ
|
 |
 |
 |
 |
Date :
2012-04-08 07:24:19 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|