Note that there are some explanatory texts on larger screens.

plurals
  1. POmysqli_fetch_array Returning One Row Within TCPDF
    primarykey
    data
    text
    <p>The code below shows a php query I am trying to execute within TCPDF. However the query I am running only seems to display one row from the database when there are 3 results that should be returned in the table. Having looked at numerous examples I understand that the line:</p> <pre><code>while($row = mysqli_fetch_array($result)) </code></pre> <p>Is the main reason for only returning one row. Here is the bulk of the code to return the Quantity, Description, Unit Price and Line Price. I just need each row to sit underneath each other. Any help would be greatly appreciated... </p> <pre><code>$con=mysqli_connect("localhost","username","password","db"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $result5 = mysqli_query($con,"SELECT * FROM b_sale_basket WHERE ORDER_ID=$ID"); while($row = mysqli_fetch_array($result5)) { $quantity = $row["QUANTITY"]; $description = $row["NAME"]; $unitprice = $row["PRICE"]; $lineprice = $row["PRICE"]*$row["QUANTITY"]; } $tbl_header = '&lt;table style="width: 650px;" cellspacing="0" cellpadding="5"&gt;'; $tbl_footer = '&lt;/table&gt;'; $tbl = ''; // foreach item in your array... $tbl .= ' &lt;tr&gt; &lt;td style="width: 50px; text-align: left;"&gt;&lt;p style="color:#808080;"&gt;'.$quantity.'&lt;/p&gt;&lt;/td&gt; &lt;td style="width: 400px;"&gt;&lt;p style="color:#808080;"&gt;'.$description.'&lt;/p&gt;&lt;/td&gt; &lt;td style="width: 125px;"&gt;&lt;p style="color:#808080;"&gt;'.$unitprice.'&lt;/p&gt;&lt;/td&gt; &lt;td style="width: 75px; text-align:right;" align="right"&gt;&lt;p style="color:#808080;"&gt;'.$lineprice.'&lt;/p&gt;&lt;/td&gt; &lt;/tr&gt; '; $pdf-&gt;writeHTML($tbl_header . $tbl . $tbl_footer, true, false, false, false, ''); mysql_close($con); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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