|
|
|
ใส่ ลำดับตัวเลขใน รายงาน pdf จากdatabase รบกวนด้วยครับ |
|
|
|
|
|
|
|
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;
}
//Better table
function ImprovedTable($header,$data)
{
//Column widths
$w=array(10,20,20,30,25,25,40);
//Header
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,iconv('UTF-8','TIS-620',$header[$i]),1,0,'C');
$this->Ln();
//Data
foreach ($data as $eachdata)
{
$this->Cell(10,6,iconv('UTF-8','TIS-620',$i),1);
$this->Cell(20,6,iconv('UTF-8','TIS-620',$eachdata["rec_id"]),1);
$this->Cell(20,6,iconv('UTF-8','TIS-620',$eachdata["dd"]),1);
$this->Cell(30,6,iconv('UTF-8','TIS-620',$eachdata["mm"]),1);
$this->Cell(25,6,iconv('UTF-8','TIS-620',$eachdata["yy"]),1,0,'C');
$this->Cell(25,6,iconv('UTF-8','TIS-620',$eachdata["total_car"]),1,0,'R');
$this->Cell(40,6,iconv('UTF-8','TIS-620',$eachdata["name"]),1,0,'R');
$this->Ln();
}
//Closure line
$this->Cell(array_sum($w),0,'','T');
}
}//end class
$pdf=new PDF();
//Column titles
$header=array ('ลำดับ','เลขที่บิล','วัน','เดือน','ปี','รถทั้งหมด','รับรถจาก');
//Data loading
//*** Load MySQL Data ***//
$strSQL = "select * from store";
$objQuery = mysql_query($strSQL);
$resultData = array();
for ($x=0;$x<mysql_num_rows($objQuery);$x++)
{
$result = mysql_fetch_array($objQuery);
array_push($resultData,$result);
}
//************************//
//$pdf->SetFont('Arial','',10);
//*** Table 2 ***//
$pdf->AddPage();
$pdf->AddFont('angsa','','angsa.php');
$pdf->SetFont('angsa','',14);
$pdf->Image('logo.png',80,8,33);
$pdf->Ln(35);
$pdf->ImprovedTable($header,$resultData);
$pdf->Output("MyPDF/report_store.pdf","F");
?>
ดาวน์โหลดรายงาน <a href="MyPDF/report_store.pdf">Clickhere</a>
คืออยากใส่ ลำดับเลข ตามรายงานที่ออกมาอ่าครับ ต้องใส่ตัวแปรตรงไหนครับ
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2012-07-16 09:20:57 |
By :
nutsza |
View :
1643 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
//Data
$rang=0;
foreach ($data as $eachdata)
{
$this->Cell(10,6,iconv('UTF-8','TIS-620',$rang),1);
$this->Cell(20,6,iconv('UTF-8','TIS-620',$eachdata["rec_id"]),1);
$this->Cell(20,6,iconv('UTF-8','TIS-620',$eachdata["dd"]),1);
$this->Cell(30,6,iconv('UTF-8','TIS-620',$eachdata["mm"]),1);
$this->Cell(25,6,iconv('UTF-8','TIS-620',$eachdata["yy"]),1,0,'C');
$this->Cell(25,6,iconv('UTF-8','TIS-620',$eachdata["total_car"]),1,0,'R');
$this->Cell(40,6,iconv('UTF-8','TIS-620',$eachdata["name"]),1,0,'R');
$this->Ln();
$rang++;
}
|
|
|
|
|
Date :
2012-07-16 09:36:07 |
By :
Krungsri |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากครับผมได้แล้ว
|
|
|
|
|
Date :
2012-07-16 09:46:27 |
By :
nutsza |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|