|
 |
|
ขอ code php เกี่ยวกับทำรายงาน คือต้องการให้เลือกเป็นช่วงเวลาได้ จากวันที่ - วันที่ ครับขอบคุณครับ |
|
 |
|
|
 |
 |
|

Code (PHP)
<form name="form1" method="get" action="">
<tr>
<td align="center"><p><b>ยอดชำระเงินการขายสินค้า</b></p>
<br>
</td>
</tr>
<tr>
<td width="100%"><div align="left">เลือกเดือน
<select name="mm" class="txtbox" id="mm">
<?
if($_POST["mm"] == "")
{
$_POST["mm"]=date("m");
}
?>
<option value="1" <? if($_POST["mm"]==1){ print "selected"; }?>>มกราคม</option>
<option value="2" <? if($_POST["mm"]==2){ print "selected"; }?>>กุมพาพันธ์</option>
<option value="3" <? if($_POST["mm"]==3){ print "selected"; }?>>มีนาคม</option>
<option value="4" <? if($_POST["mm"]==4){ print "selected"; }?>>เมษายน</option>
<option value="5" <? if($_POST["mm"]==5){ print "selected"; }?>>พฤษภาคม</option>
<option value="6" <? if($_POST["mm"]==6){ print "selected"; }?>>มิถุนายน</option>
<option value="7" <? if($_POST["mm"]==7){ print "selected"; }?>>กรกฎาคม</option>
<option value="8" <? if($_POST["mm"]==8){ print "selected"; }?>>สิงหาคม</option>
<option value="9" <? if($_POST["mm"]==9){ print "selected"; }?>>กันยายน</option>
<option value="10" <? if($_POST["mm"]==10){ print "selected"; }?>>ตุลาคม</option>
<option value="11" <? if($_POST["mm"]==11){ print "selected"; }?>>พฤศจิกายน</option>
<option value="12" <? if($_POST["mm"]==12){ print "selected"; }?>>ธันวาคม</option>
</select>
ปี
<select name="yy" class="txtbox" id="yy">
<?
if($_POST["yy"] == "")
{
$_POST["yy"]=date("Y");
}
?>
<option value="2005" <? if($_POST["yy"]==2005){ print "selected"; }?>>2548</option>
<option value="2006" <? if($_POST["yy"]==2006){ print "selected"; }?>>2549</option>
<option value="2007" <? if($_POST["yy"]==2007){ print "selected"; }?>>2550</option>
<option value="2008" <? if($_POST["yy"]==2008){ print "selected"; }?>>2551</option>
<option value="2009" <? if($_POST["yy"]==2009){ print "selected"; }?>>2552</option>
<option value="2010" <? if($_POST["yy"]==2010){ print "selected"; }?>>2553</option>
<option value="2011" <? if($_POST["yy"]==2011){ print "selected"; }?>>2554</option>
<option value="2012" <? if($_POST["yy"]==2012){ print "selected"; }?>>2555</option>
<option value="2013" <? if($_POST["yy"]==2013){ print "selected"; }?>>2556</option>
<option value="2014" <? if($_POST["yy"]==2014){ print "selected"; }?>>2557</option>
<option value="2015" <? if($_POST["yy"]==2015){ print "selected"; }?>>2558</option>
<option value="2016" <? if($_POST["yy"]==2016){ print "selected"; }?>>2559</option>
<option value="2017" <? if($_POST["yy"]==2017){ print "selected"; }?>>2560</option>
<option value="2018" <? if($_POST["yy"]==2018){ print "selected"; }?>>2561</option>
<option value="2019" <? if($_POST["yy"]==2019){ print "selected"; }?>>2562</option>
<option value="2020" <? if($_POST["yy"]==2020){ print "selected"; }?>>2563</option>
</select>
<input type="submit" class="button" value="ดูรายงาน">
</div>
</td>
</tr>
</form>
</table>
<br>
<table cellspacing=0 cellpadding=3 width="93%" bgcolor=#CCCCCC border=1 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td bgcolor="#68ca6a"><div align="center">ลำดับ</div></td>
<td bgcolor="#68ca6a"><div align="center">วันที่</div></td>
<td bgcolor="#68ca6a"><div align="center">เลขที่สั่งใบสั่งซื้อ</div></td>
<td bgcolor="#68ca6a"><div align="center">วันที่ส่งสินค้า</div></td>
<td bgcolor="#68ca6a"><div align="right">จำนวน (บาท)</div></td>
</tr>
<?
function Thai_date($day){
$date = explode("-",$day);
$thyear = $date[0];
$month = $date[1];
$thday = $date[2];
if($thday <10)
$thday = substr($thday,1,1);
$thMonth = array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน",
"กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
$thyear +=543;
$day = $thday." ".$thMonth[$month-1]." ".$thyear;
return $day;
}
$i=0;
//**เลือกข้อมูลใบสั่งซื้อสินค้า
$sql = "select * From order_report Where 1 and MONTH(Date)='".$_GET["mm"]."' and YEAR(Date)='".$_GET["yy"]."' and status='2' order by OrderNo desc ";
$query = mysql_query($sql);
While($result= mysql_fetch_array($query)){
$i++;
?>
<tr bgcolor=#e5e5e5>
<td width="61" bgcolor="#FFFFFF"><div align="center">
<?=$i;?>
</div></td>
<td width="174" bgcolor="#FFFFFF"><div align="center">
<?= Thai_date($result["Date"]);?>
</div></td>
<td width="139" align="center" bgcolor="#FFFFFF"> <a href="order_detail.php?OrderNo=<?=$result["OrderNo"];?>" target="_blank">
<?=$result["OrderNo"];?>
</a></td>
<td width="196" align="center" bgcolor="#FFFFFF">
<?
if($result["sentdate"]=="0000-00-00")
{
?>
<a href="status.php?OrderNo=<?=$result["OrderNo"];?>">กำหนดวันที่</a>
<?
}
else
{
print Thai_date($result["sentdate"]);
}
?>
</td>
<td width="102" bgcolor="#FFFFFF"> <div align="right"></div>
<div align="right">
<?=number_format($result["Total"], 2,'.',',');?>
<?
$total=$total+$result["Total"];
?>
</div></td>
</tr>
<?
}
?>
</tbody>
</table>
<table cellspacing=0 cellpadding=1 width="93%" bgcolor=#CCCCCC border=1 align="center" height="10">
<tbody>
<tr bgcolor=#e5e5e5>
<td width="604" bgcolor="#FFFFFF"><div align="right">สรุปยอดขาย (บาท)</div>
</td>
<td width="100" bgcolor="#FFFFFF">
<div align="right">
<?=number_format($total, 2,'.',',');?>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</table><br>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2013-02-21 08:00:52 |
By :
Nuiz |
View :
3446 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รอหน่อยนะ เด๋วก็มีคนใจดีเขียนมาให้.... 
|
 |
 |
 |
 |
Date :
2013-02-21 08:43:11 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จ้ะ
|
 |
 |
 |
 |
Date :
2013-02-21 09:12:56 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|