如何使用Dompdf在while循环上打印表以获取数据的数据?使用Dompdf在While循环上的输出表
下面是我已经完成的代码,但失败的结果。
$html = '<table>
<tr>
<td>Date</td><td>Name</td>
</tr>';
// Query from mysql
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$date = $row['date '];
$name = $row['name'];
$html . = '<tr>
<td> ' . $date . ' </td>' . $name . '</td>
</tr>';
}
}
$html .= '</table>';
require('../dompdf/autoload.inc.php');
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("Result.pdf",array("Attachment"=>0));
$dompdf->clear();
现在你去和编辑把它标记为编辑,说明你犯了一个错误。 –
抱歉@ Fred-ii-但是如何将它标记为编辑?我在更新中提到了我正在对代码 – Amran
进行更正*“堆栈提示”*:无论何时您犯了一个错误,您都需要在您的(已编辑)问题中指定您将代码更改为应该已经正确的语法。这主要是因为,当人们根据您最初发布的内容发布答案时,其他人会用正确的语法查看答案,并将其与您现在所拥有的内容进行比较,并可能会告诉自己:*“他们有正确的语法,为什么答案?“*他们可能会因此而降低答案。因此,请始终将您的“新”代码放在原始问题的下面,并使用**“编辑:**”和一个快速说明;-) –