Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Instead of creating a whole new document inside the while loop, you can just loop on the table row:</p> <p>First setup your $compare variable (Notice <code>[TABLE_ROWS]</code> inside the string variable $compare):</p> <pre><code>$compare = '&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Compare Packages&lt;/title&gt; &lt;style type="text/css"&gt; .print_title{ font-family:Arial, Helvetica, sans-serif; font-size:20px; font-weight:bold; color:#000; } .print_text{ font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#000000; } .print_bold{ font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#000000; font-weight:bold; } .print_footer{ font-family:Arial, Helvetica, sans-serif; font-size:9px; color:#000000; } .print_big{ font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#000000; font-weight:bold; } body{ margin:0px; } table td{ height:1px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;table class="print_text" align="left"&gt; &lt;tr&gt; &lt;td width="200px" class="print_bold" align="right"&gt;Package&lt;/td&gt;&lt;td width="100px" class="print_bold" align="center"&gt;Package 1&lt;/td&gt;&lt;td width="100px" class="print_bold" align="center"&gt;Package 2&lt;/td&gt;&lt;td width="100px" class="print_bold" align="center"&gt;Package 3&lt;/td&gt;&lt;td width="100px" class="print_bold" align="center"&gt;Package 4&lt;/td&gt; &lt;/tr&gt; [TABLE_ROWS] &lt;/table&gt; &lt;/body&gt; &lt;/html&gt;'; </code></pre> <p>Then get all the rows to display:</p> <pre><code>while($row=mysql_fetch_array($packages)){ $table_rows .= '&lt;tr&gt; &lt;td class="print_bold" align="right"&gt;Bank Code:&lt;/td&gt;&lt;td width="100px" align="center"&gt;'.$row['bank_name'].'&lt;/td&gt;&lt;td width="100px" align="center"&gt;display 2nd bank&lt;/td&gt;&lt;td width="100px" align="center"&gt;display 3rd bank&lt;/td&gt;&lt;td width="100px" align="center"&gt;display 4th bank&lt;/td&gt; &lt;/tr&gt;'; } $compare = str_replace('[TABLE_ROWS]', $table_rows, $compare); </code></pre> <p>Then call the rest of your code:</p> <pre><code>include_once('dompdf/dompdf_config.inc.php'); $dompdf = new DOMPDF(); $dompdf-&gt;load_html($compare); $dompdf-&gt;render(); $dompdf-&gt;stream('Compare_Packages.pdf'); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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