1

我有一个mysql查询,结果如下:

$retval = 
Array ( [0] => Array ( [Attestation] => urkVIII,194b ) [1] => Array ( [Attestation] => urkVIII,195e ) [2] => Array ( [Attestation] => urkVIII,208a ) [3] => Array ( [Attestation] => urkVIII,213 )  ) 

我想使用TCPDF. 我对此很TCPDF陌生,即使使用示例似乎也能得到它。我试过了,但我只得到最后一个结果(urkVIII,213)

foreach ($retval as $row)
{
  foreach ($row as $result)
  {  
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->AddPage();
     $pdf->writeHTML($result, true, false, true, false, '');
  } 
}
$pdf->Output('somefile.pdf', 'I');

我想我必须使用一个while循环,但我试过没有成功。你能帮助我吗?

4

1 回答 1

0
if($retval->num_rows()>0){
 foreach ($retval->result() as $row){
  $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  $pdf->AddPage();
  $pdf->writeHTML($row, true, false, true, false, '');
  } 
}
于 2013-07-29T11:08:41.883 回答