|
|
|
การออกรายงานใช้แบบ fpdf แต่พอขึ้นหน้าใหม่หัวตารางไม่ขึ้น |
|
|
|
|
|
|
|
Code (PHP)
<?
require('fpdf.php');
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;
}
function Header(){
//$this->Image('op.jpg',87,0,40);
$this->AddFont('angsa','','angsa.php');
$this->SetFont('angsa','',15);
$this->Cell(0,0,iconv( 'UTF-8','TIS-620','หน้าที่... '.$this->PageNo()),0,1,"R");
$this->Ln(20);
}
//Simple table
function BasicTable($header,$data)
{
//Header
$w=array(20,30,30,25,25,30,20);
//Header
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,iconv('UTF-8','cp874',$header[$i]),1,0,'C');
//$pdf->Write(5,iconv('UTF-8','cp874' , 'อะไร ' ));
$this->Ln();
//Data
foreach ($data as $eachResult)
{
$this->Cell(20,6,$eachResult["room_id"],1,0,'C');
$this->Cell(30,6,$eachResult["status1"],1,0,'C');
$this->Cell(30,6,$eachResult["room_name"],1,0,'C');
$this->Cell(25,6,$eachResult["room_class"],1,0,'C');
$this->Cell(25,6,$eachResult["room_arkan"],1,0,'C');
$this->Cell(30,6,$eachResult["id_room_type"],1,0,'C');
$this->Cell(20,6,$eachResult["status"],1,0,'C');
$this->Ln();
}
}
}
$pdf=new PDF();
$header=array('ลำดับ','status1','room_name','room_class','room_arkan','id_room_type','status');
//Data loading
//***Load MySQL Data***//
@mysql_connect("localhost", "root", "root") or die(mysql_error());
$objdb=mysql_select_db("test");
mysql_query("SET character_set_results=tis620");
mysql_query("SET character_set_client=tis620");
mysql_query("SET character_set_connection=tis620");
$sql = "select * from room ";
$dbquery = mysql_query($sql);
$resultData = array();
for($i=0;$i<mysql_num_rows($dbquery);$i++){
$result = mysql_fetch_array($dbquery);
array_push($resultData,$result);
}
//$pdf->SetFont('Arial','',10);
$pdf->AddFont('angsa','','angsa.php');
$pdf->SetFont('angsa','',12);
$pdf->AddPage();
$pdf->Ln(10);
$pdf->BasicTable($header,$resultData);
$pdf->Output("",'I');
?>
Tag : PHP
|
|
|
|
|
|
Date :
2016-08-25 19:49:38 |
By :
look_pla |
View :
1445 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จะต้องสร้างหัวตัวตารางสำหรับหน้าใหม่ด้วยครับ
|
|
|
|
|
Date :
2016-08-26 09:31:12 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณค่ะ
|
|
|
|
|
Date :
2016-08-27 21:45:25 |
By :
lookpla |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|