خرید بک لینک
Hi Guys,

I would like to export my data which I select from a table into separate excel files until all the rows have been exported. I used the below code. It is working fine for exporting only once. I would like to know is there a way to export to multiple files until all the loop ends ?

PHP Code:

if(isset($_GET['groupname'], $_GET['decks'], $_GET['rows']))
   {
 
    
$groupname $_GET['groupname'];
    
$decks $_GET['decks'];
    
$rows $_GET['rows'];    
    
$pickdeckrows $rows/$decks;
 
  
//  for($i=1; $i<=$decks; $i++){
 
      
$stmt $dbcoect->prepare("SELECT v.decknumber, v.vtext  FROM decks v WHERE  v.groupname =:groupname LIMIT :pickdeckrows");
      
$stmt -> bindValue(':groupname'$groupname);
      
$stmt -> bindValue(':pickdeckrows'$pickdeckrows);
      
$stmt -> execute();
 
      
ob_end_clean();
 
      
$output '
       <table class="table" bordered="1">  
        <tr>  
             <th>GroupId</th>  
             <th>Text</th>
        </tr>
      '
;
      while(
$row $stmt -> fetch())
      {
       
$output .= '
        <tr>  
             <td>'
.$row["decknumber"].'</td>  
             <td>'
.$row["vtext"].'</td>
        </tr>
       '
;
      }
      
$output .= '</table>';
      
header('Content-Type: application/vnd.ms-excel');
      
header('Content-Disposition: attachment; filename='.$groupname.'deck.xls');
      echo 
$output;
 
      
$stmtdelete $dbcoect->prepare("DELETE  FROM decks WHERE  groupname =:groupname LIMIT :pickdeckrows");
      
$stmtdelete -> bindValue(':groupname'$groupname);
      
$stmtdelete -> bindValue(':pickdeckrows'$pickdeckrows);
      
$stmtdelete -> execute();
 
   
// }    
  


Thanks.

برچسب: نویسنده: آیلین رضوانی تاريخ: سه شنبه 14 شهريور 1396 ساعت: 18:46

صفحه بندی