Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $servername = "localhost";
- $username = "user_name";
- $password = "password";
- $dbname = "db_name";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT SUM((IFNULL(main_table.base_total_invoiced, 0) - IFNULL(main_table.base_tax_invoiced, 0) - IFNULL(main_table.base_shipping_invoiced, 0) - (IFNULL(main_table.base_total_refunded, 0) - IFNULL(main_table.base_tax_refunded, 0) - IFNULL(main_table.base_shipping_refunded, 0))) * main_table.base_to_global_rate) AS `lifetime`, AVG((IFNULL(main_table.base_total_invoiced, 0) - IFNULL(main_table.base_tax_invoiced, 0) - IFNULL(main_table.base_shipping_invoiced, 0) - (IFNULL(main_table.base_total_refunded, 0) - IFNULL(main_table.base_tax_refunded, 0) - IFNULL(main_table.base_shipping_refunded, 0))) * main_table.base_to_global_rate) AS `average` FROM `sales_order` AS `main_table` WHERE ( main_table.status NOT IN ( 'canceled' ) ) AND ( main_table.state NOT IN ( 'new', 'pending_payment' ) ) limit 0,1";
- ?>
- <div class="box-body table-responsive no-padding">
- <table class="table table-hover">
- <tr>
- <th> total sale</th>
- <th>
- average sale</th>
- </tr>
- <tr>
- <?php
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- ?>
- <td><?php echo $row['lifetime'];?></td>
- <td><?php echo $row['average'];?></td>
- <?php
- }
- } else {
- echo "0 results";
- }
- $conn->close();
- ?>
- </tr>
- </table>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment