2012-07-19 3 views
6

나는 이제 TCPDF는 HTML 기능을 사용하여 해당 테이블에서 PDF를 생성합니다이TCPDF에서 PHP 스크립트를 사용하는 방법은 무엇입니까?

expedition_name | Phone | CP | 
__________________________________________ 
    Starsindo | 09890 | John | 
    Iron Bird | 09891 | Gina | 
    MSA Cargo | 09890 | John | 

같은 데이터베이스의 테이블이있다.

는하지만 아직도

<?php 

require_once('tcpdf/config/lang/eng.php'); 
require_once('tcpdf/tcpdf.php'); 

// create new PDF document 
include "koneksi.php"; 
    $sql = "SELECT * FROM tb_exp_local"; 
    $hasil = mysql_query($sql); 
    $data = mysql_fetch_array($hasil); 

    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 

    // set font 
    $pdf->SetFont('times', '', 11); 

    // add a page 
    $pdf->AddPage(); 



    $html = '<h2>List Of Expediton</h2> //Title 
<table border="1" cellspacing="3" cellpadding="4"> 
    <tr> 
     <th>Expedition</th>    //head of column name 
     <th align="center">Phoine</th> //head of column name 
     <th align="center">CP</th>  //head of column name 
    </tr> 
    while($data=mysql_fetch_array($hasil)) 
    { 
    <tr> 
     <td>$data[nama_exp]</td> 
    </tr> 
    } 
</table>'; 


    $pdf->writeHTML($html, true, false, true, false, ''); 


    $pdf->Output('Local Expedition, 'I'); 

?> 
가 가

는 누구든지 나를 도울 수 이 같은 내 코드가 어떻게 그것을 해결하기 위해 것을 결합하는 방법을 혼동? 그리고 데이터는 PDF로 쓸 수 있습니까?

+0

및 오류/문제는 무엇인가? – k102

답변

7
당신은 같은 것을 사용하여 HTML을 준비해야

:

$html = '<h2>List Of Expediton</h2> //Title 
    <table border="1" cellspacing="3" cellpadding="4"> 
    <tr> 
     <th>Expedition</th>    //head of column name 
     <th align="center">Phoine</th> //head of column name 
     <th align="center">CP</th>  //head of column name 
    </tr>'; 

while($data=mysql_fetch_array($hasil)) { 
    $html .= '<tr><td>'.$data['nama_exp'].'</td></tr>'; 
} 
$html .= '</table>'; 
+0

+1 답장을주세요. – mrsrinivas

관련 문제