|
|
|
ขอสอบถามวิธีการสั่งให้ pdf ขึ้นหน้าใหม่ เมื่อข้อมูลเปลี่ยนไปตามเงื่อนไข |
|
|
|
|
|
|
|
กำหนด buffer เพี่อเก็บค่าเก่าของ CountryCode
Code (PHP)
$buffer = '';
while( $ro=$rs->fetch_assoc()){
if( $buffer!=$CountryCode){
if($buffer>''){
$pdf->AddPage(); // คำสั่งนี้หรือเปล่าไม่รู้นะครับ แค่เดาเอา
}
$buffer = $CountryCode;
}
}
|
|
|
|
|
Date :
2015-10-17 05:27:59 |
By :
NewbiePHP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รบกวนช่วยดแนะนำหน่อยครับว่า จะขึ้นหน้าไหมได้อย่างไร ถ้า zone เปลี่ยนไป
code ครับ
Code (PHP)
<html>
<head>
<title>รายชื่อพนักงานเริ่มงาน</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?
$today_date=date("d-M-Y");
?>
<?php
define('FPDF_FONTPATH','font/');
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;
}
//Page header
//Page header
function Header()
{
$this->SetFont('Arial','B',15);
//Move to the right
$this->Cell(20);
//Title
$this->SetFillColor(235,0,0);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->Cell(150,7,'Check List Confirm Parttime Join Date.',1,0,'C');
//Line break
$this->Ln(15);
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$w=array(12,60,20,25,15,25,28);
$this->SetFont('Arial','B',10);
$header=array('Title','Name','Surname','Mobile','Branch','Start','End');
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
//Line break
$this->Ln(7);
}
//Page footer
function Footer()
{
//Position at 1.5 cm from bottom
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial','I',8);
//Page number
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
}
//Colored table
function FancyTable($header,$data)
{
//Colors, line width and bold font
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//Header
$w=array(12,60,20,25,15,25,25);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],0,iconv('UTF-8', 'cp874', $header[$i]),1,0,'C',true);
//$this->Ln();
//Color and font restoration
$this->SetFillColor(224,230,255);
$this->SetTextColor(0);
$this->SetFont('');
//Data
$fill=false;
foreach($data as $eachResult)
{
$this->Cell($w[0],8,iconv('UTF-8','cp874',$eachResult["user"]),'LR',0,'L',$fill);
$this->Cell($w[1],8,iconv('UTF-8','cp874',$eachResult["branch"]),'LR',0,'L',$fill);
$this->Cell($w[2],8,iconv('UTF-8','cp874',$eachResult["zone"]),'LR',0,'L',$fill);
$this->Cell($w[3],8,$eachResult["mobile"],'LR',0,'C',$fill);
$this->Cell($w[4],8,$eachResult["location"],'LR',0,'C',$fill);
$this->Cell($w[6],8,$eachResult["startdate"],'LR',0,'C',$fill);
$this->Cell($w[7],8,$eachResult["enddate"],'LR',0,'C',$fill);
$this->Ln();
$fill=!$fill;
}
$this->Cell(array_sum($w),0,'','T');
}
}
//Column titles
//$header=array('คำนำ','ชื่อ','นามสกุล','เบอร์โทร','สาขา','แผนก','วันที่เริ่มงาน','วันที่สิ้นสุด');
//*** Load MySQL Data ***//
$objConnect = mysql_connect("localhost","bpworld_root","root") or die("Error Connect to Database");
@mysql_query("SET NAMES UTF8");
$objDB = mysql_select_db("bpworld_opencart");
$strSQL = "select user , branch , zone FROM user ";
$objQuery = mysql_query($strSQL);
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
$result = mysql_fetch_array($objQuery);
array_push($resultData,$result);
}
//$pdf->SetFont('Arial','',10);
$pdf=new PDF();
$pdf->AddFont('angsana','','angsa.php');
$pdf->AddFont('angsana','B','angsab.php');
$pdf->AddFont('angsana','I','angsai.php');
$pdf->AddFont('angsana','BI','angsaz.php');
$pdf->SetFont('angsana','',12);
//*** Table 3 ***//
$pdf->AddPage();
$pdf->FancyTable($header,$resultData);
$pdf->Output("MyPDF/MyPDF.pdf","F");
?>
PDF Created Click <a href="MyPDF/MyPDF.pdf">here</a> to Download
</body>
</html>
|
|
|
|
|
Date :
2015-10-19 21:32:14 |
By :
sranuwat |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|