TCPDF

2016-06-27 10 views
0

私はPHPでTCPDFを使用していますが、私は表に印刷されていないテーブル全体のレコードを生成するために、問題に直面していて、テーブル内のレコードを生成するが、それは私のコードはここにTCPDF

<?php 
    require_once('lang/eng.php'); 
    require_once('tcpdf_include.php'); 

    if (trim($_POST['pdfid']) == "All") { 
     $qry = "select master.hcid,hcmaster.hcname,master.instdate,master.sendname,master.address,statemaster.statename,master.district,master.mobile,master.receiptm,master.subject,master.disposal,master.dispdate,MASTER.dispdetail,master.remark 
from master JOIN hcmaster ON master.hcname=hcmaster.hcid 
     JOIN statemaster ON master.state=statemaster.stateid "; 
    } 
     else { 
     $qry = "select master.hcid,hcmaster.hcname,master.instdate,master.sendname,master.address,statemaster.statename,master.district,master.mobile,master.receiptm,master.subject,master.disposal,master.dispdate,MASTER.dispdetail,master.remark 
from master JOIN hcmaster ON master.hcname=hcmaster.hcid 
     JOIN statemaster ON master.state=statemaster.stateid WHERE id = '" . $_POST['pdfid'] . "'"; 
    } 

    if ($qry) { 
     $tbdata = ''; 
     $con = mysqli_connect("localhost", "root", "", "dakmanagement"); 
     $res = mysqli_query($con, $qry) or die("not fire"); 



     if (mysqli_num_rows($res)!=0) 
     { 
      $i = 1; 
      while($row=mysqli_fetch_array($res, MYSQLI_ASSOC)) 
      { 
          $tbdata .= '<tr><td colspan="3">&nbsp;</td></tr><tr><td width="10%" align="left">' . $i . 
'</td> 
        <td width="75%"><table width="100%" border="1" cellpadding="2"> 
              <tr> 
          <td width="20%" align="left">Id No:</td> 
          <td width="30%" align="left">' . $row['hcid'] . '</td> 
                <td width="20%" align="left">Recv_Mode:</td> 
          <td width="30%" align="left">' . $row['receiptm'] . '</td> 
         </tr> 
         <tr> 
          <td colspan="2" width="20%" align="left">Name:</td> 
                <td colspan="2" width="80%" align="left">' . $row['hcname'] . '</td> 
         </tr> 
         <tr> 
          <td colspan="2" width="20%" align="left">Subject:</td> 
          <td colspan="2" width="80%" align="left">' . $row['subject'] . '</td> 
         </tr> 
         <tr> 
          <td colspan="2" width="20%" align="left">Address:</td> 
          <td colspan="2" width="80%" align="left">' . $row['address'] . '</td> 
         </tr> 
         <tr> 
          <td colspan="2" width="20%" align="left">Disp_dtls:</td> 
          <td colspan="2" width="80%" align="left">' . $row['dispdate'] . '-' . $row['dispdetail'] . '</td> 
         </tr> 
       </table></td> 
          <td width="15%" align="right">' . $row['instdate'] . '<br/>' . $row['dispdate'] . '</td></tr> 
          '; 
        $i++; 

       } 
     } 

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

    // set document information 
     $pdf->SetCreator(PDF_CREATOR); 
     $pdf->SetAuthor('Vinay Soni'); 
     $pdf->SetTitle('High Court'); 
     $pdf->SetSubject('High Court'); 
     $pdf->SetKeywords('High Court'); 


    // set margins 
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); 
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); 
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); 

    // set auto page breaks 
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); 

    // set some language-dependent strings (optional) 
     if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { 
      require_once(dirname(__FILE__) . '/lang/eng.php'); 
      $pdf->setLanguageArray($l); 
     } 

    // --------------------------------------------------------- 
    // set font 
     $pdf->SetFont('dejavusans', '', 10); 

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

    // writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=false, $align='') 
    // writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true) 
    // create some HTML content 
     $html = ' 
    <div style="width:100%; float:left;"> 
     <p style="font-weight: bold; font-size: 20px; text-align: center;">RAJASTHAN HIGH COURT BENCH JAIPUR.<br/> 
      <span style="font-weight: bold; font-size: 18px; text-align: center;">Hon`ble CJ Secretariat</span> 
     </p> 
    </div>  
    <table width="100%" border="1"> 
     <tr > 
      <th align="left">S.No.</th> 
      <th align="center">Complete Detail of Records</th> 
      <th align="right" >Inst_date<br/>Disp_date</th> 
     </tr> 
     ' . $tbdata . ' 
    </table> 
    '; 
    // output the HTML content 
     $pdf->writeHTML($html, true, false, true, false, ''); 

    // reset pointer to the last page 
     $pdf->lastPage(); 

    //Close and output PDF document 
     $pdf->Output('Report.pdf', 'I'); 
    } 
    ?> 
+0

エラーhttp://phppot.com/demo/generate-pdf-from-mysql-data-using-fpdf/にテーブルを使用しようとするのに役立ちますか? –

答えて

0

あるアレイ内のすべてのレコードを取得する方法このリンクは、あなたが示したPDF