Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //export.php
- $connect = mysqli_connect("localhost", "username", "password", "dbname");
- $output = '';
- if(isset($_POST["export"]))
- {
- $query = "
- select trim(ifnull(application, 'Grand Total' )) as Application,
- ifnull(sum(Totalcapacity) ,0.00) as 'Capacity (Gig)'
- from storagedata group by application with rollup
- ";
- $result1 = mysqli_query($connect, $query);
- $result2 = mysqli_query($connect, $query);
- $dataRow = "";
- while($row2 = mysqli_fetch_array($result2))
- {
- $dataRow = $dataRow."<tr><td>$row2[0]</td><td>$row2[1]</td></tr>";
- }
- <head>
- <title>Returning Total Capacity Per DC</title>
- </head>
- <body>
- <!-- Building table -->
- <table align = 'center' border='2' width='300' height='100'>
- <tr>
- <td colspan='2' align='center' bgcolor='lightblue'><b>Total Capacity by DC</b> </td>
- </tr>
- <tr>
- <th>Datacenter</th>
- <th>Total Capacity (Gig)</th>
- </tr>
- <?php while($row1 = mysqli_fetch_array($result1)):;?>
- <tr>
- <td><?php echo $row1[0];?></td>
- <td><?php echo $row1[1];?></td>
- </tr>
- <?php endwhile;?>
- </body>
- <br><br>
- $output .= '</table>';
- header('Content-Type: application/xlsx;');
- header('Content-Disposition: attachment; filename=download.xlsx');
- echo $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement