php while 最后一个,PHP While循环只显示最后一行

我正在使用TCPDF库来生成表格的PDF.

表的行数很少,比如10

其中两行有相同的发票号码“78650”

现在我按发票编号选择,并根据需要生成两行PDF.

但它只是获取第二行,即最后一行.那就是序列号2只被采用.

代码如下:

require_once('TCPDF/tcpdf.php');

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {

require_once(dirname(__FILE__).'/lang/eng.php');

$pdf->setLanguageArray($l);

}

$pdf->SetFont('helvetica', '', 9);

$pdf->AddPage();

$html1 = '

SL No.ProductDescriptionQtyTotal

$sql = ("select * from invoice WHERE invoice_no = 78650 ORDER BY invoice_id ASC");

$result=mysqli_query($connection,$sql);

$i = 1;

while($row = mysqli_fetch_array($result)){

$pr = $row['product'];

$dr = $row['description'];

$qty = $row['qty'];

$total = $row['total'];

$html2 = "

".$i."".$pr."".$dr."".$qty."".$total."";

$i++; }

$sql_1 = ("select *,SUM(total)as tot from invoice WHERE invoice_no = 78650 GROUP BY invoice_no");

$result_1=mysqli_query($connection,$sql_1);

$row_1 = mysqli_fetch_array($result_1);

$tot = $row_1['tot'];

$html3 = "

Total: ".$tot."";

$html = $html1.$html2.$html3;

$pdf->writeHTML($html, true, 0, true, 0);

$pdf->lastPage();

$pdf->Output('htmlout.pdf', 'I');

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值