Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > PHP export PDF ไม่แสดงข้อมูล รบกวนแนะนำหน่อยครับ ว่าใช้วิธีไหนดี



 

PHP export PDF ไม่แสดงข้อมูล รบกวนแนะนำหน่อยครับ ว่าใช้วิธีไหนดี

 



Topic : 111642



โพสกระทู้ ( 124 )
บทความ ( 0 )



สถานะออฟไลน์




SQL ถูกนะครับ ลิงค์จากอีกหน้ามา

sgdsdf

จากรูปด้านบน ผมใช้โค้ดตามนี้ครับ
Code (PHP)
<?php
define('FPDF_FONTPATH','font/');
require('../assets/pdf/fpdf.php');
include '../../DBEngine.php';
mysql_query("SET NAMES UTF8");
$reserve_start = $_GET['reserve_start'];
$reserve_end = $_GET['reserve_end'];
$strSQL ="select * from tb_reserve_detail 
					left join tb_reserve on (reserve=reserve_id)
					left join tb_hall on (reserve_detail_hall=hallid)
					left join tb_member on (tb_reserve.member=tb_member.member)
					where reserve_detail_start between '$reserve_start' and '$reserve_end' order by reserve_detail_id DESC";
$objQuery = mysql_query($strSQL);

function DateThai($x) {
  $thai_m = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฏาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
  $date_array = explode("-", $x);
  $y = $date_array[0];
  $m = $date_array[1] - 1;
  $d = (int) $date_array[2];
  $m = $thai_m[$m];
  $y = $y + 543;
  $displaydate = "$d $m $y";
  return $displaydate;
}


function MonthThai($value) {
$month = $value;
		switch($month) {
			case 01 : $month = "มกราคม"; break;
			case 02 : $month = "กุมภาพันธ์"; break;
			case 03 : $month = "มีนาคม"; break;
			case 04 : $month = "เมษายน"; break;
			case 05 : $month = "พฤศภาคม"; break;
			case 06 : $month = "มิถุนายน"; break;
			case 07 : $month = "กรกฏาคม"; break;
			case 08 : $month = "สิงหาคม"; break;
			case 09 : $month = "กันยายน"; break;
			case 10 : $month = "ตุลาคม"; break;
			case 11 : $month = "พฤศจิกายน"; break;
		default : $month = "ธันวาคม";	
		}
		return $month;
}
function DateTime($value) {
		$date = substr($value,0,10); 
		$time = substr($value,10,19);
		echo DateThai($date);
		$val = $time." น.";
		return $val;
}

function booking_status($value) {
	switch($value) {
		case 1 : 	return '<font color="#339900">อนุมัติ</font>';	 break;
		case 2 : 	return '<font color="#CC6600">ไม่อนุมัติ</font>';	 break;
		case 3 : 	return '<font color="#CC6600">ยกเลิกการจอง</font>';	 break;
	default : 	return '<font color="#CC6600">รอการตรวจสอบ</font>';	 break;
	}
}

class PDF extends FPDF
{
 
// 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 No. '.$this->PageNo(),0,0,'L');
}

 

/* pdf */



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(95,95);
	//Header
	for($i=0;$i<count($header);$i++)
		//$this->Cell($w[$i],7,$header[$i],1,0,'C');
		$this->Cell($w[$i],7,iconv('UTF-8', 'TIS-620', $header[$i]),1,0,'L');
	$this->Ln();
	//Data
	foreach ($data as $eachResult) 
	{
		$this->Cell(95,17,iconv( 'UTF-8','TIS-620',"
							    <strong>".$eachResult['reserve_title']."</strong><br />
        <span style='font-size: 14px;'> &nbsp;&nbsp;".$eachResult['reserve_detail']." <br />
          โดย : ".$eachResult['member_fristname']."&nbsp; ".$eachResult['member_lastname']."<br />
          หมายเหตุ : ".$eachResult['reserve_remark'] ),1,0,'C');
		$this->Cell(95,17,iconv( 'UTF-8','TIS-620',
							   "<strong>".$eachResult['hall_name']."</strong><br /><span style='font-size: 14px;'>ตั้งแต่วันที่ &nbsp;:&nbsp;".DateThai($eachResult['reserve_detail_start'])."&nbsp;".$eachResult['reserve_detail_strtime']."&nbsp;น.<br /> สิ้นสุดวันที่ :&nbsp;".DateThai($eachResult['reserve_detail_end'])."&nbsp;".$eachResult['reserve_detail_endtime']."&nbsp;น.</span><br /> 
							   สถานะการจอง : ".booking_status($eachResult['reserve_detail_status'])) ,1,0,'C');
		$this->Ln();
	}
}

//Better table
function ImprovedTable($header,$data)
{
	//Column widths
	$w=array(95,95);
	//Header
	for($i=0;$i<count($header);$i++)
		$this->Cell($w[$i],7,$header[$i],1,0,'L');
		//$this->Cell($w[$i],7,iconv('UTF-8', 'cp874', $header[$i]),1,0,'C');
	$this->Ln();
	//Data

	foreach ($data as $eachResult) 
	{
			$this->Cell(95,17,iconv( 'UTF-8','TIS-620',"<strong>".$eachResult['reserve_title']."</strong><br /><span style='font-size: 14px;'> &nbsp;&nbsp;".$eachResult['reserve_detail']." <br />
โดย : ".$eachResult['member_fristname']."&nbsp; ".$eachResult['member_lastname']."<br />
	หมายเหตุ : ".$eachResult['reserve_remark'] ),1,0,'L');
		$this->Cell(95,17,iconv( 'UTF-8','TIS-620',"<strong>".$eachResult['hall_name']."</strong><br /><span style='font-size: 14px;'>ตั้งแต่วันที่ &nbsp;:&nbsp;".DateThai($eachResult['reserve_detail_start'])."&nbsp;".$eachResult['reserve_detail_strtime']."&nbsp;น.<br /> สิ้นสุดวันที่ :&nbsp;".DateThai($eachResult['reserve_detail_end'])."&nbsp;".$eachResult['reserve_detail_endtime']."&nbsp;น.</span><span style='font-size: 14px;'><br /> 
สถานะการจอง : ".booking_status($eachResult['reserve_detail_status'])),1,0,'L');
		$this->Ln();
 ;
	}





	//Closure line
	$this->Cell(array_sum($w),0,'','T');
}

//Colored table
function FancyTable($header,$data)
{
	//Colors, line width and bold font
	$this->SetFillColor(47,49,49);
	$this->SetTextColor(255);
	$this->SetDrawColor(0,0,0);
	$this->SetLineWidth(.3);
	$this->SetFont('angsa','',12);
	//Header
	$w=array(95,95);
	for($i=0;$i<count($header);$i++)
		$this->Cell($w[$i],7,$header[$i],1,0,'L',true);
		//$this->Cell($w[$i],7,iconv('UTF-8', 'cp874', $header[$i]),1,0,'C');
	$this->Ln();
	//Color and font restoration
	$this->SetFillColor(224,235,255);
	$this->SetTextColor(0);
	$this->SetFont('angsa','',12);
	//Data
	$fill=false;
	foreach($data as $row)
	{
		$this->Cell(95,17,iconv( 'UTF-8','TIS-620',"<strong>".$eachResult['reserve_title']."</strong><br /><span style='font-size: 14px;'> &nbsp;&nbsp;".$eachResult['reserve_detail']." <br />
โดย : ".$eachResult['member_fristname']."&nbsp; ".$eachResult['member_lastname']."<br />
	หมายเหตุ : ".$eachResult['reserve_remark']),'LR',0,'L',$fill);
		$this->Cell(95,17,iconv( 'UTF-8','TIS-620',"<strong>".$eachResult['hall_name']."</strong><br /><span style='font-size: 14px;'>ตั้งแต่วันที่ &nbsp;:&nbsp;".DateThai($eachResult['reserve_detail_start'])."&nbsp;".$eachResult['reserve_detail_strtime']."&nbsp;น.<br /> สิ้นสุดวันที่ :&nbsp;".DateThai($eachResult['reserve_detail_end'])."&nbsp;".$eachResult['reserve_detail_endtime']."&nbsp;น.</span><span style='font-size: 14px;'><br /> 
สถานะการจอง : ".booking_status($eachResult['reserve_detail_status']) ),'LR',0,'L',$fill);
 
		$this->Ln();
		$fill=!$fill;
	}
	$this->Cell(array_sum($w),0,'','T');
}
}






$pdf=new PDF();
//Column titles
$pdf->AddFont('angsa','','angsa.php');
$pdf->SetFont('angsa','',12);
//Column titles
$title = iconv( 'UTF-8','TIS-620','หัวเรื่องการจองศาลาการเปรียญ');
$booking = iconv( 'UTF-8','TIS-620',' ศาลาการเปรียญ / ช่วงเวลาการจอง');
 

$header=array("$title","$booking" );
//Data loading

//*** Load MySQL Data ***//

//require("ThaiPDF.class.php");

$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->AddFont('angsana','I','angsai.php');
$pdf->AddFont('angsana','BI','angsaz.php');
$pdf->SetFont('angsana','',12);
//$pdf->SetFont('Arial','',10);



/*** Table 1 
$pdf->AddPage();
$pdf->Image('logo.png',80,8,33);
$pdf->Ln(35);
$pdf->BasicTable($header,$resultData);

//*** Table 2
$pdf->AddPage();
$pdf->Image('logo.png',80,8,33);
$pdf->Ln(35);
$pdf->ImprovedTable($header,$resultData);  ***/

//*** Table 3 ***//
 
$pdf->AddPage();
$pdf->SetMargins(10,10,10,10);
$pdf->SetFont('angsa','',20);
$pdf->cell(0,0,iconv( 'UTF-8','TIS-620',"รายงานการจองศาลาการเปรียญ : ".DateThai($reserve_start)." - ".DateThai($reserve_end)),0,1,"L");
$pdf->Ln(7);
$pdf->FancyTable($header,$resultData);
 
$pdf->Output();
?>


ผมไม่แน่ใจว่า กำหนดให้แสดงข้อความใน cell ยังไง เลยลองทำดู ผมเคยแต่แสดงค่าตัวแปรที่ได้จากฐานข้อมูลตรงๆ เลยมันแสดงได้ แต่
ต้องการให้มีเนื้อหาประกอบด้วย มันไม่ยอมแสดง รบกวนขั้นเทพแนะนำหน่อยครับ ^^

อันนี้คือบนเว็บที่ยังไม่ได้ออกมา PDF
g

ถ้าจะให้ออกมาประมาณนี้สามารถทำได้ไหมครับ



Tag : PHP









ประวัติการแก้ไข
2014-10-01 02:04:56
2014-10-01 02:28:54
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-10-01 02:04:15 By : coolkidz View : 862 Reply : 3
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

เป็น Form HTML แบบนี้ไม่ลองดูพวก TCPDF ล่ะครับ สามารถแปลงจาก HTML เป็น PDF ได้เลย






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-10-01 09:51:24 By : mr.win
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook



อีกตัวหนึ่งครับ mPDF สามารถ Convert จาก HTML เป็น PDF ได้เลย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-10-01 09:52:04 By : mr.win
 

 

No. 3



โพสกระทู้ ( 124 )
บทความ ( 0 )



สถานะออฟไลน์


ว๊าววว ขอบคุณครับท่าน TC Admin
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-10-01 18:44:50 By : coolkidz
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : PHP export PDF ไม่แสดงข้อมูล รบกวนแนะนำหน่อยครับ ว่าใช้วิธีไหนดี
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่