Guest User

Untitled

a guest
May 27th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <?php
  2. include 'Library/sqlserverconnect.php';
  3.  
  4. $query = "SELECT type, sum(quantity) as quantity, avg(price) as price
  5. FROM `test`
  6. WHERE station = 'P2 Monkey Island' OR station = 'P2 Monkey Island' OR station = 'HW The Cliff' OR station = 'C4C The Ook Emporium' group by type
  7. order by (sum(quantity)*avg(price))";
  8. $result = mysql_query($query) or die('<br />Query failed: ' . mysql_error().'<br /><p>'.$query.'</p>');
  9. $total;
  10. echo "<table border = 1 Width = 100%>\n";
  11. echo "\t<tr>\n";
  12. echo "\t\t<th>Item</th>\n";
  13. echo "\t\t<th>Quantity</th>\n";
  14. echo "\t\t<th>Total Price</th>\n";
  15. echo "\t\t<th>Total Volume</th>\n";
  16. echo "\t</tr>\n";
  17. $totalvolume;
  18. while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
  19. {
  20. $query2 = "select volume from invtypes where typename like '".mysql_real_escape_string($line['type'])."'";
  21. $result2 = mysql_query($query2) or die('<br />Query failed: ' . mysql_error().'<br /><p>'.$query2.'</p>');
  22. $line2 = mysql_fetch_array($result2, MYSQL_ASSOC);
  23. echo '<tr>';
  24. echo '<td>'.$line['type'].'</td>';
  25. echo '<td>'.$line['quantity'].'</td>';
  26. echo '<td>'.$line['price'] * $line['quantity'].'</td>';
  27. echo '<td>'.$line2['volume'] * $line['quantity'].'</td>';
  28. echo '</tr>';
  29. $total += $line['price'] * $line['quantity'];
  30. $totalvolume += $line2['volume'] * $line['quantity'];
  31. }
  32. echo '</table>';
  33. $rawtotal = $total;
  34. $fee = $total*.0155;
  35. $total = $total-$total*.0155;
  36.  
  37. echo 'Total Sales: '.number_format($rawtotal,2,'.',',').'<br/>';
  38. echo 'Total Fees: '.number_format($fee,2,'.',',').'<br/>';
  39. echo 'Total m3: '.$totalvolume.'<br/>';
  40.  
  41. echo 'Estimated Cost: '.number_format($rawtotal / 1.2,2,'.',',') .'<br/>';
  42. $total -= ($rawtotal / 1.2);
  43. echo 'Estimated profit: '.number_format($total,2,'.',',').'<br/>';
  44.  
  45. ?>
Add Comment
Please, Sign In to add comment