|
 |
|
ช่วยแก้หน่อยครับ มันไม่แสดงค่าออกมา ไม่ทราบว่ามีวิธีไหนบ้างครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
require('fpdf.php');
define('FPDF_FONTPATH','font/');
class PDF extends FPDF
{
//Load data
function LoadData($file)
{
//Read file lines
$lines=file($file);
$data=array();
foreach($lines as $line)
$data[]=explode(';',chop($line));
return $data;
}
//Simple table
function BasicTable($header,$data)
{
//Header
$w=array(15,40,30,30,30,30);
//Header
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],10,iconv('UTF-8', 'TIS-620', $header[$i]),1,0,'C');//เซตหัวข้อเป็นไทย
$this->Ln();
//Data
foreach ($data as $eachResult)
{
$this->Cell(15,6,$i,1,0,'C');
$this->Cell(40,6,$eachResult["pro_name"],1,0,'C');
$this->Cell(30,6,$eachResult["amount"],1,0,'C');
$this->Cell(30,6,number_format($eachResult["pro_price"],2,'.',','),1,0,'C');
$this->Cell(30,6,number_format($eachResult["price_send"],2,'.',','),1,0,'C');
$this->Cell(30,6,number_format(($eachResult["pro_price"]+$eachResult["price_send"])*$eachResult["amount"],2,'.',','),1,0,'C');
$this->Ln();
}
}
function BasicTable2($data)
{
//Data
foreach ($data as $eachResult)
{//ส่วนต้นฉบับ
$this->setXY( 10, 6);//เซตตำแหน่ง
$this->Cell(0,0,$i,1,0,'C');//แสดงข้อมูลจากฐานข้อมูล
$this->setXY( 10, 6);//เซตตำแหน่ง
$this->Cell(0,0,$eachResult["pro_name"],1,0,'C');//แสดงข้อมูลจากฐานข้อมูล
$this->setXY( 10, 6);//เซตตำแหน่ง
$this->Cell(0,0,$eachResult["amount"],1,0,'C');//แสดงข้อมูลจากฐานข้อมูล
$this->setXY( 10, 6);//เซตตำแหน่ง
$this->Cell(0,0,number_format($eachResult["pro_price"],2,'.',','),1,0,'C');//แสดงข้อมูลจากฐานข้อมูล
$this->setXY( 10, 6);//เซตตำแหน่ง
$this->Cell(0,0,number_format($eachResult["price_send"],2,'.',','),1,0,'C');//แสดงข้อมูลจากฐานข้อมูล
$this->setXY( 10, 6);//เซตตำแหน่ง
$this->Cell(0,0,number_format(($eachResult["pro_price"]+$eachResult["price_send"])*$eachResult["amount"],2,'.',','),1,0,'C');//แสดงข้อมูลจากฐานข้อมูล
$this->setXY( 10, 6);//เซตตำแหน่ง
$this->Ln();
}
}
}
$pdf=new PDF();
//Column titles
$header=array('ลําดับ','รายการ','จํานวน','ราคาต่อหน่วย','ค่าจัดส่ง','จํานวนเงิน');
//Data loading
//*** Load MySQL Data ***//
include("Connection.php");
mysql_query("SET NAMES TIS620");
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client=tis620");
mysql_query("SET character_set_connection=tis620");
$sql="SELECT order_detail.orderNO,order_detail.amount,product.*,orderlist.price_totale from order_detail INNER JOIN product ON(order_detail.pro_id=product.pro_id) INNER JOIN orderlist ON(orderlist.orderNO=order_detail.orderNO) WHERE order_detail.orderNO='$orderNO' ";
$objQuery = mysql_query($sql);
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
$result = mysql_fetch_array($objQuery);
array_push($resultData,$result);
}
//************************//
$pdf->AddFont('angsana','','angsa.php');//เพิ่มอักษรไทย
$pdf->AddFont('angsana','B','angsab.php');
$pdf->SetFont('angsana','',16);
//สร้างเอกสาร หัวกระดาษ
$pdf->AddPage();
$pdf->setXY( 10,10);//เซตตำแหน่ง
//$pdf->MultiCell( 0 , 0 , iconv( 'UTF-8','cp874' , ) );
//$pdf->setXY( 10, 20);//เซตตำแหน่ง
//$pdf->MultiCell( 0 , 0 , iconv( 'UTF-8','cp874' , ) );
$pdf->setXY( 80, 30);//เซตตำแหน่ง
$pdf->MultiCell( 0 , 0 , iconv( 'UTF-8','cp874' , 'ใบเสร็จรับเงิน' ) );
$pdf->Ln(5);
$pdf->BasicTable($header,$resultData);
/*$pdf->setXY( 20,120);//เซตตำแหน่ง*/
/*$pdf->MultiCell( 0 , 0 , iconv( 'UTF-8','cp874' , 'จึงเรียนมาเพื่อโปรดทราบ' ) );
$pdf->setXY( 140,155);//เซตตำแหน่ง
$pdf->MultiCell( 0 , 0 , iconv( 'UTF-8','cp874' , '.................................................' ) );
$pdf->setXY( 150,165);//เซตตำแหน่ง
$pdf->MultiCell( 0 , 0 , iconv( 'UTF-8','cp874' , 'อาจารย์ประจำวิชา' ) );*/
/*$pdf->BasicTable2($resultData);*/
$pdf->Output("reportPDF1.pdf");
?>
<a href="reportPDF1.pdf">สินค้าที่ต้องสั่งซื้อในแต่ละครั้ง</a>
</body>
</html>
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2011-11-18 23:50:38 |
By :
aaa |
View :
838 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ออกรายงาน pdf
|
 |
 |
 |
 |
Date :
2011-11-18 23:51:46 |
By :
banana7 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รายละเอียดมากกว่านี้ครับ 
|
 |
 |
 |
 |
Date :
2011-11-20 21:22:36 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|