【发布时间】:2017-08-09 15:51:34
【问题描述】:
我在使用 FPDF 时遇到问题,我想创建一个 While 循环,它返回我使用 Phpmyadmin 时我的 SQL 查询执行的每个结果,这里的问题是它只返回一个。如果我使用
$pdf->Cell(190,10,''.$pdf_info2['format'].'',1,1,0);
它确实打印了我想要的结果,但我需要在表格中返回它们,如下所示。
Ps:这是我的第一个问题,所以如果我不是很清楚我的问题,我很抱歉。
提前致谢
$html='<table border="0">
<tr>
<td width="150" height="40" bgcolor="#e6e6e6">Tipo</td>
<td width="150" height="40" bgcolor="#e6e6e6">Formato</td>
<td width="150" height="40" bgcolor="#e6e6e6"> </td>
<td width="150" height="40" bgcolor="#e6e6e6">Pago</td>
<td width="150" height="40" bgcolor="#e6e6e6">Editar</td>
</tr>';
while($pdf_info2 = $smth->fetch(PDO::FETCH_ASSOC)) {
$html2 = '<tr>
<td width="150" height="40" bgcolor="#e6e6e6">'.$pdf_info['format'].'</td>
<td width="150" height="40" bgcolor="#e6e6e6">.$pdf_info['format'].</td>
<td width="150" height="40" bgcolor="#e6e6e6">.$pdf_info['format'].</td>
<td width="150" height="40" bgcolor="#e6e6e6">.$pdf_info['format'].</td>
<td width="150" height="40" bgcolor="#e6e6e6">.$pdf_info['format'].</td>
</tr>';
}
$pdf->WriteHTML($html);
$pdf->WriteHTML($html2);
【问题讨论】:
-
$html2 .=看到=前面的那个点了吗? -
而
$pdf_info['format']应该是$pdf_info2['format']。