Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <?php
  2. //export.php
  3. $connect = mysqli_connect("localhost", "username", "password", "dbname");
  4. $output = '';
  5. if(isset($_POST["export"]))
  6. {
  7. $query = "
  8. select trim(ifnull(application, 'Grand Total' )) as Application,
  9. ifnull(sum(Totalcapacity) ,0.00) as 'Capacity (Gig)'
  10. from storagedata group by application with rollup
  11. ";
  12.  
  13. $result1 = mysqli_query($connect, $query);
  14.  
  15. $result2 = mysqli_query($connect, $query);
  16.  
  17. $dataRow = "";
  18.  
  19. while($row2 = mysqli_fetch_array($result2))
  20.  
  21. {
  22. $dataRow = $dataRow."<tr><td>$row2[0]</td><td>$row2[1]</td></tr>";
  23.  
  24. }
  25.  
  26. <head>
  27.  
  28. <title>Returning Total Capacity Per DC</title>
  29.  
  30. </head>
  31.  
  32. <body>
  33.  
  34. <!-- Building table -->
  35. <table align = 'center' border='2' width='300' height='100'>
  36. <tr>
  37. <td colspan='2' align='center' bgcolor='lightblue'><b>Total Capacity by DC</b> </td>
  38. </tr>
  39. <tr>
  40. <th>Datacenter</th>
  41. <th>Total Capacity (Gig)</th>
  42.  
  43. </tr>
  44.  
  45. <?php while($row1 = mysqli_fetch_array($result1)):;?>
  46. <tr>
  47. <td><?php echo $row1[0];?></td>
  48. <td><?php echo $row1[1];?></td>
  49.  
  50. </tr>
  51. <?php endwhile;?>
  52. </body>
  53. <br><br>
  54.  
  55. $output .= '</table>';
  56. header('Content-Type: application/xlsx;');
  57. header('Content-Disposition: attachment; filename=download.xlsx');
  58. echo $output;
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement