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 > พี่ๆครับ พอจะทราบ code ออกรายงาน php หรือป่าวครับ ช่วยผมหน่อยนะครับ ออกมาเป็น PDF ครับ



 

พี่ๆครับ พอจะทราบ code ออกรายงาน php หรือป่าวครับ ช่วยผมหน่อยนะครับ ออกมาเป็น PDF ครับ

 



Topic : 108800



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



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




พี่ๆครับ พอจะทราบ code ออกรายงาน php หรือป่าวครับ ช่วยผมหน่อยนะครับ ออกมาเป็น PDF ครับ

ดึงออกมาจากตารางฐานข้อมูลครับ



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-05-31 14:43:13 By : nonzabboy View : 956 Reply : 13
 

 

No. 1



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



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


ช่วยผมหน่อยนะครับๆๆๆ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-05-31 15:25:08 By : nonzabboy
 


 

No. 2



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



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


ก็ต้องเป็นพวก FPDF TCPDF อะไรทำนองนั้นครับ

ถ้าไม่อยากปวดหัว/ไม่มีเวลาศึกษา
แนะนำให้ใช้ javascript:window.print() แล้วตอนเลือกไดฟ์เวอร์เครื่องพิมพ์เราก็เลือกไปที่บันทึกเป็น PDF กดพิมพ์
ออกมาเป็นไฟล์ PDF ได้เช่นกัน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-05-31 15:43:32 By : meannerss
 

 

No. 3



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



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


อ่อ ครับ แต่ตอนนี้ผมได้ได้แล้ว ครับ ติดตรงที่ไม่เป็น ภาษาไทย อะครับ เป็นภาษา ต่างดาวไปหมดเลยครับ ใส่ UTF 8 ก็ไม่เป็นอะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-05-31 15:54:47 By : nonzabboy
 


 

No. 4



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



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

ใช้ tcpdf ครับ ภาษาไทย 100 %


ตัวอย่าง ที่ผมมออกรายงาน
Code (PHP)
<?
session_start ();
$id = $_GET['id'];
?>
<?php
include("../tcpdf/setPDF.php");
// เพิ่มหน้าใน PDF 
$pdf->AddPage();
//set font และ ขนาด
$pdf->SetFont('freeserif', '', 8);



//connect db
mysql_connect ("localhost","root","1412") or die (mysql_error());
mysql_select_db ("e-export");
mysql_query ("SET NAMES UTF8");

//ทำการ join ตาราง และ เรียกข้อมูลตาม id
					$sql = mysql_query ("select * from service s, service2 s2, service3 s3, boat b, bill bi where s.s_id = s2.s_id && s.s_id = s3.s_id && s.boat_id = b.boat_id && s.s_id = bi.s_id && s.s_id = '$id' ");
				
					$show = mysql_fetch_assoc ($sql);
					
								

$htmlcontent='<table width="100%" border="1" align="center">
  <tr>
    <th colspan="2" bgcolor="#70B2D6" scope="col"><strong>DRAFT BILL OF LOADING </strong><strong></strong></th>
  </tr>
  <tr>
    <th width="50%" scope="col"><table width="100%" border="0">
      <tr>
        <th scope="col"><div align="left">Shipper : </div></th>
      </tr>
      <tr>
        <th scope="col"><div align="left">&nbsp;'.$show[name_from].''.$show[phone_from].'</div></th>
      </tr>
      <tr>
        <th scope="col"><div align="left">&nbsp;'.$show[company_from].'</div></th>
      </tr>
      <tr>
        <th scope="col"><div align="left">&nbsp;'.$show[address_from].''.$show[city_from].''.$show[state_from].''.$show[country_from].''.$show[zipcode_from].'</div></th>
      </tr>
    </table></th>
    <th width="50%" rowspan="2" valign="top" scope="col"><table width="100%" border="0">
      <tr>
        <th scope="col"><div align="left"><font color=red>Receipt No. '.$show[receipt].'</font></div></th>
        </tr>
    </table>
      <table width="100%" height="204" border="0">
        <tr>
          <th height="26" scope="col"><img src="../../img/banner/banner.png" width=250 height=100 /></th>
        </tr>
        <tr>
          <th scope="col"><div align="left">E-export CO ., LTD </div></th>
        </tr>
        <tr>
          <th scope="col"><div align="left"></div></th>
        </tr>
        <tr>
          <th scope="col"><div align="left"></div></th>
        </tr>
      </table></th>
  </tr>
  <tr>
    <th scope="col"><table width="100%" border="0">
      <tr>
        <th scope="col"><div align="left">Consignee : </div></th>
      </tr>
      <tr>
        <th scope="col"><div align="left">&nbsp;'.$show[name_to].''.$show[phone_to].'</div></th>
      </tr>
      <tr>
        <th scope="col"><div align="left">&nbsp;'.$show[company_to].'</div></th>
      </tr>
      <tr>
        <th scope="col"><div align="left">&nbsp;'.$show[address_to].''.$show[city_to].''.$show[state_to].''.$show[country_to].''.$show[zipcode_to].'</div></th>
      </tr>
    </table></th>
  </tr>
  
  <tr>
    <th scope="col"><table width="100%" border="0">
      <tr>
        <th scope="col"><div align="left">Occen Vessel : </div></th>
        <th scope="col"><div align="left">Port of Loading : </div></th>
      </tr>
      
      <tr>
        <th scope="col"><div align="left">'.$show[name_boat].'</div></th>
        <th scope="col"><div align="left">LAEM CHABANG, THAILAND</div></th>
      </tr>
    </table></th>
    <th width="50%" valign="bottom" scope="col"><table width="100%" border="0">
      <tr>
        <th scope="col"><div align="left">Freight Payable at : </div></th>
        </tr>
      <tr>
        <th scope="col"><div align="left">DESTINATION</div></th>
      </tr>
    </table></th>
  </tr>
  <tr>
    <th colspan="2" scope="col"><table width="100%" border="0">
      <tr>
        <th width="22%" scope="col">Marke and Number </th>
        <th width="15%" scope="col">Quantity</th>
        <th width="17%" scope="col">Description of Goods </th>
        <th width="23%" scope="col">Gross Weight (KGS) </th>
        <th width="23%" scope="col">Meesurement (CMB) </th>
      </tr>
      <tr>
        <th scope="col">'.$show[company_to].''.$show[address_to].''.$show[city_to].''.$show[state_to].''.$show[country_to].''.$show[zipcode_to].'</th>
        <th width="15%" scope="col">'.$show[amount1].'</th>
        <th width="17%" scope="col">'.$show[desciption].'</th>
        <th width="23%" scope="col">'.$show[widths].'*'.$show[longs].'*'.$show[hights].'</th>
        <th width="23%" scope="col">'.$show[total_dim].'</th>
      </tr>
    </table></th>
  </tr>
  <tr>
    <th colspan="2" scope="col"><table width="100%" border="0">
      <tr>
        <th width="35%" rowspan="2" scope="col"><div align="left">Other costs : '.number_format ($show[service1],2).' ฿ Paperless : '.number_format ($show[service2],2).' ฿ TOTAL : '.number_format ($show[total_price],2).' ฿</div></th>
        <th width="28%" scope="col"><div align="left">CFS/CFS </div></th>
        <th width="41%" valign="top" scope="col"><div align="left">DATED : '.$show[date_receipt].'</div></th>
      </tr>
      <tr>
        <th scope="col"><div align="left">FREIGHT COLLECT</div></th>
        <th width="35%" valign="top" scope="col"><div align="left">VESSEL :  '.$show[name_boat].'&nbsp;'.$show[start].'&nbsp;-&nbsp;'.$show[stop].'</div></th>
      </tr>
    </table></th>
  </tr>
  <tr>
    <th colspan="2" scope="col"><table width="100%" border="0">
      <tr>
        <th width="50%" scope="col"><table width="100%" border="0">
          <tr>
            <th scope="col"><div align="left">Place and date of issue : '.$show[start].' '.$show[date_receipt].'</div></th>
          </tr>
        </table></th>
        <th width="47%" scope="col"><table width="100%" border="0">
          <tr>
            <th scope="col"><div align="left">E-export CO ., LTD </div></th>
          </tr>
        </table></th>
      </tr>
      
    </table></th>
  </tr>
  <tr>
    <th colspan="2" bgcolor="#70B2D6" scope="col">&nbsp;</th>
  </tr>
</table>';
			  
			  
$pdf->writeHTML($htmlcontent); 

// เลื่อน pointer ไปหน้าสุดท้าย
$pdf->lastPage();

// ปิดและสร้างเอกสาร PDF
$pdf->Output('DRAFT BILL OF LOADING .pdf', 'I');




?>



ผลลัพธ์
1


ประวัติการแก้ไข
2014-05-31 21:21:40
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-05-31 21:07:10 By : topza1412
 


 

No. 5



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



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


ครับ ขอบคุณครับผม
code เยอะมากๆๆครับ มีแค่ไฟล์ เดียวหรอครับ include("../tcpdf/setPDF.php"); มาจากไหนหรอครับ ผม งง มากๆ ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-05-31 22:10:07 By : nonzabboy
 


 

No. 6



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



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


Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP PDF</title>
</head>
<body>

<?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;
}

//Simple table
function BasicTable($header,$data)
{
	//Header
	$w=array(30,30,55,25,20,20);
	//Header
	for($i=0;$i<count($header);$i++)
		$this->Cell($w[$i],7,$header[$i],1,0,'C');
	$this->Ln();
	//Data
	foreach ($data as $eachResult) 
	{
		$this->Cell(30,6,$eachResult["Registrationin"],1);
		$this->Cell(30,6,$eachResult["SubscribeNumberin"],1);
		$this->Cell(55,6,$eachResult["Datesin"],1);
		$this->Cell(25,6,$eachResult["Fromin"],1);
		$this->Cell(20,6,$eachResult["Subjectin"],1);
		$this->Cell(20,6,$eachResult["note"],1);
		$this->Ln();
	}
}

}

$pdf=new PDF();
//Column titles
$header=array('เลขทะเบียน','ที่','ลงวันที่','จาก','เรื่อง','หมายเหตุ');
//Data loading

//*** Load MySQL Data ***//
$objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database");
$objDB = mysql_select_db("registration");
mysql_query ("SET NAMES UTF8");;
$strSQL = "SELECT * FROM registration_in";
$objQuery = mysql_query($strSQL);
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
	$result = mysql_fetch_array($objQuery);
	array_push($resultData,$result);
}
//************************//





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





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

PDF Created Click <a href="MyPDF/MyPDF.pdf">here</a> to Download
</body>
</html>


ผลลัพธ์

12121212


ประวัติการแก้ไข
2014-05-31 22:18:26
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-05-31 22:13:40 By : nonzabboy
 


 

No. 7



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



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

include("../tcpdf/setPDF.php"); ก้อคือเรียกใช้ tcpdf อะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-05-31 22:16:51 By : topza1412
 


 

No. 8



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



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


ทำอย่างไงก็ไม่เป็น ภาษาไทย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-05-31 23:39:45 By : nonzabboy
 


 

No. 9



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



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


ถ้าดูจากโค้ดใน คห.6 นะครับ จะเป็นไปได้ไหมว่าเรามองข้ามกฏพื้นฐานของ HTML ไป
นั้นการประกาศ แท็ก meta ให้อ่าน UTF8
ลองแทรกโค้ดนี้เข้าบรรทัดที่2 หลังเปิดแท็ก HTML ดูครับ

Code (PHP)
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
.
.
.



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-06-01 02:01:55 By : meannerss
 


 

No. 10



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



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


ผมลองใส่แล้วครับยังไม่เป็น ภาษาไทยอะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-06-01 14:51:53 By : nonzabboy
 


 

No. 11



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



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

tcpdf set font แบบนี้ยังครับ

Code (PHP)
//set font และ ขนาด
$pdf->SetFont('freeserif', '', 8);

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-06-01 21:04:50 By : topza1412
 


 

No. 12



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



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


พี่พอจะมี ไฟล์ หรือป่าวครับ เดียวผมเอามาดัดแปลง อะครับ ผม งง จิงๆๆ ตรงนี้จริงๆอะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-06-05 14:59:45 By : nonzabboy
 


 

No. 13



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



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


ขอบคุณ มากๆๆๆ นะครับตอนนี้ทำได้แล้วครับ ขอบคุณทุกๆคนเลยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-06-08 15:57:31 By : nonzabboy
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : พี่ๆครับ พอจะทราบ code ออกรายงาน php หรือป่าวครับ ช่วยผมหน่อยนะครับ ออกมาเป็น 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 04
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 อัตราราคา คลิกที่นี่