Hadi1989

Untitled

Jul 6th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <?php
  2.     header("Content-Type: application/xls");    
  3.     header("Content-Disposition: attachment; filename=download.xls");  
  4.     header("Pragma: no-cache");
  5.     header("Expires: 0");
  6.  
  7.     require_once 'conn.php';
  8.    
  9.     $output = "";
  10.    
  11.     if(ISSET($_POST['export'])){
  12.         $output .="
  13.             <table>
  14.                 <thead>
  15.                     <tr>
  16.                         <th>ID</th>
  17.                         <th>Firstname</th>
  18.                         <th>Lastname</th>
  19.                         <th>Address</th>
  20.                         <th>Job</th>
  21.                     </tr>
  22.                 <tbody>
  23.         ";
  24.        
  25.         $query = $conn->query("SELECT * FROM `member`") or die(mysqli_errno());
  26.         while($fetch = $query->fetch_array()){
  27.            
  28.         $output .= "
  29.                     <tr>
  30.                         <td>".$fetch['mem_id']."</td>
  31.                         <td>".$fetch['firstname']."</td>
  32.                         <td>".$fetch['lastname']."</td>
  33.                         <td>".$fetch['address']."</td>
  34.                         <td>".$fetch['job']."</td>
  35.                     </tr>
  36.         ";
  37.         }
  38.        
  39.         $output .="
  40.                 </tbody>
  41.                
  42.             </table>
  43.         ";
  44.        
  45.         echo $output;
  46.     }
  47.    
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment