Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP mysql display 4 results in one goal
    text
    copied!<p>I want to display the result in the PDF file. The problem now is the PDF file only can catch the first row of the while loop. Is there something like <code>row[0]['rates']</code> for the first row and <code>row[1]['rates']</code> for the second row? So I can just fetch it once and display <code>row[0]['rates']</code> and <code>row[1]['rates']</code>...</p> <p><strong>Create PDF:</strong></p> <pre><code>&lt;?php session_start(); if( empty( $_POST['compare'] ) ) include"connect_to_mysql.php"; $packages = mysql_query("SELECT*FROM package_creation WHERE id IN (". implode(',', $_POST['compare']) ." ) LIMIT 4"); while($row=mysql_fetch_array($packages)){ $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; &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; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt;'; } include_once('dompdf/dompdf_config.inc.php'); $dompdf = new DOMPDF(); $dompdf-&gt;load_html($compare); $dompdf-&gt;render(); $dompdf-&gt;stream('Compare_Packages.pdf'); ?&gt; </code></pre>
 

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