2015-12-28 32 views
0

我想通過這個循環下載我數據庫中包含的所有pdf。 當我點擊按鈕時,只有第一個文件被下載。通過HTML2PDF在一個循環中下載我的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> 

回答

1

每次下載只能提供1個文件。

你當然可以將它們全部添加到zip壓縮文件中,並提供下載。

+0

我怎麼能使她? – Guillaume

+0

舊式的方式:閱讀文檔。 :-) http://php.net/manual/en/book.zip.php –