Note that there are some explanatory texts on larger screens.

plurals
  1. POTCPDF and how to output files from database with looping
    text
    copied!<p>i have a question regarding TCPDF im trying to output data from my database and loop them i tried following the answer that was given here <a href="https://stackoverflow.com/questions/5261684/tcpdf-printing-table-from-mysql">TCPDF - printing table from mysql</a> but it doesnt properly show the contents of my database for example the supposed output is: 1 2 3 4 5</p> <p>but what happens is 1 q a w 4</p> <p>here is my code</p> <pre><code> &lt;?php include('connect.php'); require_once('libraries/tcpdf/config/lang/eng.php'); require_once('libraries/tcpdf/tcpdf.php'); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set default font subsetting mode $pdf-&gt;setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf-&gt;SetFont('dejavusans', '', 14, '', true); // Add a page // This method has several options, check the source code documentation for more information. $pdf-&gt;AddPage(); // set text shadow effect $pdf-&gt;setTextShadow(array('enabled'=&gt;true, 'depth_w'=&gt;0.2, 'depth_h'=&gt;0.2, 'color'=&gt;array(196,196,196), 'opacity'=&gt;1, 'blend_mode'=&gt;'Normal')); $query=mysql_query("select * from ci"); $query=mysql_fetch_assoc($query); $tbl_header = '&lt;table style="width: 638px;" cellspacing="0"&gt;'; $tbl_footer = '&lt;/table&gt;'; $tbl = ''; foreach($query as $query2){ $ciid = $query2['ci_id']; $cinature = $query2['ci_nature']; $ciposition = $query2['ci_postion']; $tbl .= ' &lt;tr&gt; &lt;td style="border: 1px solid #000000; width: 150px;"&gt;'.$ciid.'&lt;/td&gt; &lt;td style="border: 1px solid #000000; width: 378px;"&gt;'.$cinature.'&lt;/td&gt; &lt;td style="border: 1px solid #000000; width: 110px; text-align:center"&gt;'.$ciposition.'&lt;/td&gt; &lt;/tr&gt; ';} $pdf-&gt;writeHTML($tbl_header . $tbl . $tbl_footer, true, false, false, false, ''); $pdf-&gt;Output('test.pdf'); ?&gt; </code></pre> <p>thanks in advance </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload