Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. header("Content-Type: application/xls");    
  2. header("Content-Disposition: attachment; filename=filename.xls");  
  3. header("Pragma: no-cache");
  4. header("Expires: 0");
  5.  
  6.  
  7. echo '<table border="1">';
  8. //make the column headers what you want in whatever order you want
  9. echo '<tr><th>Field Name 1</th><th>Field Name 2</th><th>Field Name 3</th></tr>';
  10. //loop the query data to the table in same order as the headers
  11. while ($row = mysqli_fetch_assoc($result)){
  12.     echo "<tr><td>".$row['field1']."</td><td>".$row['field2']."</td><td>".$row['field3']."</td></tr>";
  13. }
  14. echo '</table>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement