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 > พอดีผมทำReport pdf โดย php ครับ ติดตรง ที่ผมอยากให้ เพิ่มน่า เมื่อข้อมูล เดือนมันถึง 12 ครับ ถ้า เดือนที่13ให้ ออกมาน่าที่ 2 ทำอย่างไรดีครับ ใครที่เคยทำพอจะช่วยได้ ช่วยบอกหน่อยน่ะครับ



 

พอดีผมทำReport pdf โดย php ครับ ติดตรง ที่ผมอยากให้ เพิ่มน่า เมื่อข้อมูล เดือนมันถึง 12 ครับ ถ้า เดือนที่13ให้ ออกมาน่าที่ 2 ทำอย่างไรดีครับ ใครที่เคยทำพอจะช่วยได้ ช่วยบอกหน่อยน่ะครับ

 



Topic : 080728



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



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




พอดีผมทำReport pdf โดย php ครับ ติดตรง ที่ผมอยากให้ เพิ่มน่า เมื่อข้อมูล เดือนมันถึง 12 ครับ ถ้า เดือนที่13ให้ ออกมาน่าที่ 2 ทำอย่างไรดีครับ ใครที่เคยทำพอจะช่วยได้ ช่วยบอกหน่อยน่ะครับCode (PHP)



Tag : PHP, HTML/CSS







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-07-08 02:29:09 By : noi014 View : 1005 Reply : 4
 

 

No. 1



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

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

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

ใช้ % เอาครับ rows%12 == 0 ก็ให้ page brake รอบหนึ่ง

Go to : PHP PDF - Header, footer, page break and image






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-08 07:13:43 By : mr.win
 


 

No. 2



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



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


Code (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;
}

//Simple table
function BasicTable($header,$header2,$header3,$data)
{
	//Header
	$w=array(15,30,30,71,71,51);
	//Header
	$this->Cell($w[0],18,iconv('UTF-8', 'TIS-620', $header[0]),1,0,'C');
	$this->Cell($w[1],9,iconv('UTF-8', 'TIS-620', $header[1]),1,0,'C');
	$this->Cell($w[2],9,iconv('UTF-8', 'TIS-620', $header[2]),1,0,'C');
	$this->Cell($w[3],9,iconv('UTF-8', 'TIS-620', $header[3]),1,0,'C');
	$this->Cell($w[4],9,iconv('UTF-8', 'TIS-620', $header[4]),1,0,'C');
	$this->Cell($w[5],9,iconv('UTF-8', 'TIS-620', $header[5]),1,0,'C');
	
	//for($i=0;$i<count($header);$i++)
	//	$this->Cell($w[$i],7,iconv('UTF-8', 'TIS-620', $header[$i]),1,0,'C');
	$this->Ln();
	//Header
	$w1=array(25,8,8,14,10,10,10,16,12,14,16,13,16,12,14,16,13,25,26,15);
	//Header
	//$this->Cell($w1[0],0,iconv('UTF-8', 'TIS-620', $header2[0]));
	$this->Cell($w1[19],0,iconv('UTF-8', 'TIS-620', $header2[19]));
	$this->Cell($w1[1],9,iconv('UTF-8', 'TIS-620', $header2[1]),1,0,'C');
	$this->Cell($w1[2],9,iconv('UTF-8', 'TIS-620', $header2[2]),1,0,'C');
	$this->Cell($w1[3],9,iconv('UTF-8', 'TIS-620', $header2[3]),1,0,'C');
	$this->Cell($w1[4],9,iconv('UTF-8', 'TIS-620', $header2[4]),1,0,'C');
	$this->Cell($w1[5],9,iconv('UTF-8', 'TIS-620', $header2[5]),1,0,'C');
	$this->Cell($w1[6],9,iconv('UTF-8', 'TIS-620', $header2[6]),1,0,'C');
	$this->Cell($w1[7],9,iconv('UTF-8', 'TIS-620', $header2[7]),1,0,'C');
	$this->Cell($w1[8],9,iconv('UTF-8', 'TIS-620', $header2[8]),1,0,'C');
	$this->Cell($w1[9],9,iconv('UTF-8', 'TIS-620', $header2[9]),1,0,'C');
	$this->Cell($w1[10],9,iconv('UTF-8', 'TIS-620', $header2[10]),1,0,'C');
	$this->Cell($w1[11],9,iconv('UTF-8', 'TIS-620', $header2[11]),1,0,'C');
	$this->Cell($w1[12],9,iconv('UTF-8', 'TIS-620', $header2[12]),1,0,'C');
	$this->Cell($w1[13],9,iconv('UTF-8', 'TIS-620', $header2[13]),1,0,'C');
	$this->Cell($w1[14],9,iconv('UTF-8', 'TIS-620', $header2[14]),1,0,'C');
	$this->Cell($w1[15],9,iconv('UTF-8', 'TIS-620', $header2[15]),1,0,'C');
	$this->Cell($w1[16],9,iconv('UTF-8', 'TIS-620', $header2[16]),1,0,'C');
	$this->Cell($w1[17],9,iconv('UTF-8', 'TIS-620', $header2[17]),1,0,'C');
	$this->Cell($w1[18],9,iconv('UTF-8', 'TIS-620', $header2[18]),1,0,'C');
	
	
	//for($i=0;$i<count($header2);$i++)
		//$this->Cell($w[$i],7,$header[$i],1,0,'C');
		//$this->Cell($w1[$i+1],7,iconv('UTF-8', 'TIS-620', $header2[$i+1]),1,0,'C');
	$this->Ln();	
	//Data
	
	foreach ($data as $eachResult) 
	{ 
	//	$this->Cell(25,7,$eachResult["name_hos"],1);
		$this->Cell(15,7,$eachResult["Month"]."/".$eachResult["Year"],1,0,'C');
		$this->Cell(8,7,$eachResult["OPD"],1,0,'C');
		$this->Cell(8,7,$eachResult["ER_IPD"],1,0,'C');
		$this->Cell(14,7,$eachResult["Refer_sum"],1,0,'C');
		$this->Cell(10,7,$eachResult["Emergency"],1,0,'C');
		$this->Cell(10,7,$eachResult["Urgency"],1,0,'C');
		$this->Cell(10,7,$eachResult["Non_urgency"],1,0,'C');
		$this->Cell(16,7,$eachResult["IN_Province"],1,0,'C');
		$this->Cell(12,7,$eachResult["IN_Zone"],1,0,'C');
		$this->Cell(14,7,$eachResult["Out_Zone"],1,0,'C');
		$this->Cell(16,7,$eachResult["Center"],1,0,'C');
		$this->Cell(13,7,$eachResult["Sum_Solder"],1,0,'C');
		$this->Cell(16,7,$eachResult["Scorn_IN_Province"],1,0,'C');
		$this->Cell(12,7,$eachResult["Scorn_IN_Zone"],1,0,'C');
		$this->Cell(14,7,$eachResult["Scorn_Out_Zone"],1,0,'C');
		$this->Cell(16,7,$eachResult["Scorn_Center"],1,0,'C');
		$this->Cell(13,7,$eachResult["Scorn_Sum"],1,0,'C');
		$this->Cell(25,7,$eachResult["Min_30"],1,0,'C');
		$this->Cell(26,7,$eachResult["Max_30"],1,0,'C');
		
		$this->Ln();
		
	}
	//$this->Ln();
	//Header
	$w2=array(15,8,8,14,10,10,10,16,12,14,16,13,16,12,14,16,13,25,26,15);
	//Header
	$this->Cell($w2[0],9,iconv('UTF-8', 'TIS-620','รวม'),1,0,'C');
	//$this->Cell($w2[19],9,iconv('UTF-8', 'TIS-620', $header3[19]),1,0,'C');
	$this->Cell($w2[1],9,iconv('UTF-8', 'TIS-620', $header3[1]),1,0,'C');
	$this->Cell($w2[2],9,iconv('UTF-8', 'TIS-620', $header3[2]),1,0,'C');
	$this->Cell($w2[3],9,iconv('UTF-8', 'TIS-620', $header3[3]),1,0,'C');
	$this->Cell($w2[4],9,iconv('UTF-8', 'TIS-620', $header3[4]),1,0,'C');
	$this->Cell($w2[5],9,iconv('UTF-8', 'TIS-620', $header3[5]),1,0,'C');
	$this->Cell($w2[6],9,iconv('UTF-8', 'TIS-620', $header3[6]),1,0,'C');
	$this->Cell($w2[7],9,iconv('UTF-8', 'TIS-620', $header3[7]),1,0,'C');
	$this->Cell($w2[8],9,iconv('UTF-8', 'TIS-620', $header3[8]),1,0,'C');
	$this->Cell($w2[9],9,iconv('UTF-8', 'TIS-620', $header3[9]),1,0,'C');
	$this->Cell($w2[10],9,iconv('UTF-8', 'TIS-620', $header3[10]),1,0,'C');
	$this->Cell($w2[11],9,iconv('UTF-8', 'TIS-620', $header3[11]),1,0,'C');
	$this->Cell($w2[12],9,iconv('UTF-8', 'TIS-620', $header3[12]),1,0,'C');
	$this->Cell($w2[13],9,iconv('UTF-8', 'TIS-620', $header3[13]),1,0,'C');
	$this->Cell($w2[14],9,iconv('UTF-8', 'TIS-620', $header3[14]),1,0,'C');
	$this->Cell($w2[15],9,iconv('UTF-8', 'TIS-620', $header3[15]),1,0,'C');
	$this->Cell($w2[16],9,iconv('UTF-8', 'TIS-620', $header3[16]),1,0,'C');
	$this->Cell($w2[17],9,iconv('UTF-8', 'TIS-620', $header3[17]),1,0,'C');
	$this->Cell($w2[18],9,iconv('UTF-8', 'TIS-620', $header3[18]),1,0,'C');
	
	
	$this->Ln();	
	
}
}

$pdf=new PDF(L,mm,A4);
//Column titles
$header=array('เดือน / ปี','ข้อมูล Refer','ระดับความรุนแรง','การประสานงาน','การถูกปฏิเสธ','เวลาประสานงาน');
$header2=array(' ','In','Out','ทั้งหมด','E','U','N','ในจังหวัด','ในเขต','ข้ามเขต','ส่วนกลาง','ทั้งหมด','ในจังหวัด','ในเขต','ข้ามเขต','ส่วนกลาง','ทั้งหมด','ภายใน 30 นาที','มากกว่า 30 นาที');
$header3=array('',$t_OPD,$t_ER_IPD,$t_Refer_sum,$t_Emergency,$t_Urgency,$t_Non_urgency,$t_IN_Province,$t_IN_Zone,$t_Out_Zone,$t_Center,$t_Sum_Solder
,$t_Scorn_IN_Province,$t_Scorn_IN_Zone,$t_Scorn_Out_Zone,$t_Scorn_Center,$t_Scorn_Sum,$t_Min_30,$t_Max_30);	
//Data loading

//*** Load MySQL Data ***//
$objConnect = mysql_connect("localhost","root","123123") or die("Error Connect to Database");
$objDB = mysql_select_db("ntdb101_db");
mysql_query("SET NAMES 'tis620' ");
$strSQL = "SELECT DISTINCT `user`.`name_hos`, `refer`.`Month`, `refer`.`Year`, `refer`.`Refer_sum`,
  `refer`.`OPD`, `refer`.`ER_IPD`, `refer`.`Emergency`, `refer`.`Urgency`,
  `refer`.`Non_urgency`, `refer`.`Sum_Solder`, `refer`.`IN_Province`,
  `refer`.`IN_Zone`, `refer`.`Out_Zone`, `refer`.`Center`, `refer`.`Scorn_Sum`,
  `refer`.`Min_30`, `refer`.`Max_30`, `refer`.`Scorn_IN_Province`,
  `refer`.`Scorn_IN_Zone`, `refer`.`Scorn_Out_Zone`, `refer`.`Scorn_Center`,
  `refer`.`Refer_id`
FROM
  `refer` INNER JOIN
  `user` ON `refer`.`user_id` = `user`.`user_id` WHERE refer.user_id = user.username AND refer.user_id='". $_SESSION["username"]."' AND refer.Unit=1  order by refer.Year desc,refer.Month desc limit $start,$limit";
$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->AddFont('angsa','','angsa.php');
	$pdf->SetFont('angsa','',16);
//*** Table 1 ***//
	
$pdf->AddPage();
$pdf->Image('logo.png',120,8,35);
$pdf->Text( 98 ,50 ,iconv('UTF-8', 'TIS-620', 'ข้อมูล'.$objResult["name_hos"]));
$pdf->Ln(45);
$pdf->BasicTable($header,$header2,$header3,$resultData);

	$pdf->Output("MyPDF/MyPDF2.pdf","F");



จากcode ข้างบน ต้องใส่ rows%12 == 0 ต้องไหนครับฝากพี่วิน ระบุให้หน่อยครับๆ ขอบคุนมากน่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-08 10:58:37 By : noi014
 

 

No. 3



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



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


ยังรออยุ่น่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-08 15:36:33 By : noi014
 


 

No. 4



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



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


เงียบเลยๆๆแก้ทั้งวันผมยังไม่ได้เลยน่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-08 17:51:04 By : noi014
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : พอดีผมทำReport pdf โดย php ครับ ติดตรง ที่ผมอยากให้ เพิ่มน่า เมื่อข้อมูล เดือนมันถึง 12 ครับ ถ้า เดือนที่13ให้ ออกมาน่าที่ 2 ทำอย่างไรดีครับ ใครที่เคยทำพอจะช่วยได้ ช่วยบอกหน่อยน่ะครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 อัตราราคา คลิกที่นี่