I would like to download all the pdfs contained in my database through this loop. When I click the button only the first file is downloaded.
<?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>
You can only offer 1 file per download.
You can of course add them all to a zip archive, and offer that for download.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.