|
|
|
PHP -- export PDF ต้องการข้อมูล แบ่งเป็น2คอลัมน์ ตรงรูปภาพหน้า2 ให้ขึ้นมาแสดงที่หน้าแรก ด้านขวา |
|
|
|
|
|
|
|
php export PDF ต้องการข้อมูล แบ่งเป็น2คอลัมน์ ตรงรูปภาพหน้า2 ให้ขึ้นมาแสดงที่หน้าแรก ด้านขวา
Code (PHP)
<?php
$id_job = $_GET['trackingNo'];
//Connect Database
$host="localhost";
$user_db="root";
$pw_db="12345678";
$db="tracking_swi";
$con=mysql_connect($host,$user_db,$pw_db);
if($con){ mysql_select_db($db);
}else{
echo "Can not connect db Server";
die();
}
$sql = "select distinct files.trackingNo, files.date, files.times, files.member_id, member.memberEng, location.Address_eng from files, location, member where files.trackingNo = '".$_GET['trackingNo']."' AND files.member_id=member.member_id AND files.Address=location.Address";//เลือกฐานข้อมูล
$strSQL = "SELECT files.FilesName, type_image.type_eng FROM files, type_image WHERE files.trackingNo='".$_GET['trackingNo']."' AND files.type_id=type_image.type_id ORDER BY files.FilesID ASC";
$dbquery = mysql_db_query($db, $sql);
$query = mysql_db_query($db, $strSQL);
$num = mysql_num_rows($dbquery);
//print $sql;
require("libs/fpdf.php");
class PDF extends FPDF
{
var $col=0;
function Header(){
$this->Image('logo.png',70,15,65);
$this->SetFont('Arial','',10);
$this->Cell(200,75,'ร้านกรุงเทพ',0,1,"C");
$this->Ln(-5);
$this->SetFont('Arial','B',18);
$this->text(80,55,'Order Invoice',0,1,"C");
$this->Rect(10, 10, 190, 275 , 'D');
}
function Footer(){
$this->SetFont('Arial','',10);
$this->SetY(-15);
$this->Cell(0,15,iconv( 'UTF-8','TIS-620','page... '.$this->PageNo()),0,1,"R");
}
}
$pdf=new PDF();
$pdf->SetMargins( 5,5,5 );
$pdf->AddPage();
$size[0] = 45;
$size[1] = 45;
//กำหนดแบบอักษรรายการ
$pdf->SetFont('Arial','',10);
//Loop
$result = mysql_fetch_array($dbquery);
$pdf->text(40,63,'Invoice No :',0,0,"L");
$pdf->text(65,63,$result['trackingNo']);
$pdf->text(120,63,'Date :');
$pdf->text(135,63,$result['date']." ".$result['times']);
$pdf->text(40,68,'Employee :');
$pdf->text(65,68,$result['member_id']." ".$result['memberEng']);
$pdf->text(120,68,'Location :');
$pdf->text(140,68,$result['Address_eng']);
$pdf->Ln(1);
//$cnt = 0;
//while ($objResult = mysql_fetch_array($query)){
//++$cnt;
//$pdf->Image("myfile/".$objResult['FilesName'],20,80, $size[0], $size[1]);
//$pdf->Cell( 50, 90, $pdf->Image("myfile/".$objResult['FilesName'], $pdf->GetX(), $pdf->GetY(), 90.90), 0, 0, 'C', false );
//$pdf->Image("myfile/".$objResult['FilesName'], 40, $pdf->GetY() + -40, 60.20);
//$pdf->Ln(20);
//$pdf->Cell(38,145,$objResult['type_eng']);
//pdf->Image(50,15,iconv('','',"myfile/{$FilesName}"),1);
//pdf->Cell(50,15,iconv('','',"{$type_eng}"),1);
//$pdf->Ln(6);
//}
$resultData = array();
for ($x=0;$x<mysql_num_rows($query);$x++)
{
$result = mysql_fetch_array($query);
array_push($resultData,$result);
}
$rang=1;
foreach($resultData as $eachdata)
{
$FilesName=$eachdata["FilesName"];
$pdf->Cell(8,50,iconv('','',' '),0,0,'L');
$pdf->Cell(4,50,iconv('','',$rang++),0,0,'C');
$pdf->Cell(35,50,iconv('','',$eachdata["type_eng"]),0,0,'C');
$pdf->Cell(50,60,iconv('','',$pdf->Image("myfile/".$eachdata['FilesName'], $pdf->GetX(), $pdf->GetY(), $size[0], $size[1])), 0, 0, 'L', false );
$pdf->Ln();
}
$pdf->Output();
?>
Tag : PHP, MySQL, HTML, CSS, HTML5
|
ประวัติการแก้ไข 2019-03-04 11:36:31
|
|
|
|
|
Date :
2019-03-04 11:31:18 |
By :
aummyasia |
View :
1010 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ mpdf จะง่ายกกว่าครับ
|
|
|
|
|
Date :
2019-03-05 17:14:41 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|