Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2. include('conetar.php');
  3. $query = "SELECT nome, contacto FROM utilizadores";
  4. $executar_query = mysqli_query($conn, $query);
  5. $contar = mysqli_num_rows($executar_query);
  6.  
  7. for($i=0;$i<1;$i++){
  8. $html[$i] = "";
  9. $html[$i] .= "<table>";
  10. $html[$i] .= "<tr>";
  11. $html[$i] .= "<td><b>Nome</b></td>";
  12. $html[$i] .= "<td><b>contacto</b></td>";
  13. $html[$i] .= "</tr>";
  14. $html[$i] .= "</table>";
  15. }
  16.  
  17. $i = 1;
  18. while($ret = mysqli_fetch_array($executar_query)){
  19. $retorno_nome = $ret['nome'];
  20. $retorno_contacto = $ret['contacto'];
  21. $html[$i] .= "<table>";
  22. $html[$i] .= "<tr>";
  23. $html[$i] .= "<td>".$retorno_nome."</td>";
  24. $html[$i] .= "<td>".$retorno_contacto."</td>";
  25. $html[$i] .= "</tr>";
  26. $html[$i] .= "</table>";
  27. $i++;
  28. }
  29.  
  30. $arquivo = 'soudev.xlsx';
  31. header ("Expires: Mon, 26 Jul 2100 05:00:00 GMT");
  32. header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT");
  33. header ("Cache-Control: no-cache, must-revalidate");
  34. header ("Pragma: no-cache");
  35. header ("Content-type: application/x-msexcel");
  36. header ("Content-Disposition: attachment; filename={$arquivo}" );
  37. header ("Content-Description: PHP Generated Data" );
  38.  
  39.  
  40. for($i=0;$i<=$contar;$i++){
  41. echo $html[$i];
  42. }
  43.  
  44.  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement