mysqli_fetch_array在TCPDF中返回一行

时间:2013-09-11 11:47:00

标签: php tcpdf

下面的代码显示了我试图在TCPDF中执行的php查询。但是,当我在表中返回3个结果时,我运行的查询似乎只显示数据库中的一行。看了很多例子,我理解了这一行:

while($row = mysqli_fetch_array($result))

是仅返回一行的主要原因。以下是返回数量,描述,单价和线价的大部分代码。我只需要每排坐在彼此下面。任何帮助将不胜感激......

$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 = '<table style="width: 650px;" cellspacing="0" cellpadding="5">';
$tbl_footer = '</table>';
$tbl = '';

// foreach item in your array...
$tbl .= '
    <tr>
        <td style="width: 50px; text-align: left;"><p style="color:#808080;">'.$quantity.'</p></td>
        <td style="width: 400px;"><p style="color:#808080;">'.$description.'</p></td>
        <td style="width: 125px;"><p style="color:#808080;">'.$unitprice.'</p></td>
        <td style="width: 75px; text-align:right;" align="right"><p style="color:#808080;">'.$lineprice.'</p></td>
    </tr>
';

$pdf->writeHTML($tbl_header . $tbl . $tbl_footer, true, false, false, false, '');

mysql_close($con);

0 个答案:

没有答案
相关问题