我想通过这个循环下载我的数据库中包含的所有 pdf。当我单击按钮时,仅下载第一个文件。
<?php
include_once('functions/functions.php');
require_once('../invoice/html2pdf.class.php');
if (isset($_GET['download'])) {
if ($_GET['download'] == 'all') {
$req = sql_query("SELECT * FROM invoice");
$content = '';
while ($res = mysqli_fetch_assoc($req)) {
$html2pdf = new HTML2PDF('P', 'A4', 'fr');
$html2pdf->setDefaultFont('Arial');
$content = $res['content'];
$html2pdf->writeHTML($content);
ob_end_clean();
$html2pdf->Output('' . $res['date'] . '-' . $res['user'] . '.pdf', 'D');
}
}
}
?>
<panel class="panel panel-flat">
<a href="invoice?download=all">Télécharger toutes les factures</a>
</panel>