Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. <?php
  2. $username = 'nmarp';
  3. $password = '';
  4.  
  5. mysql_connect('localhost',$username,$password);
  6.  
  7. mysql_select_db('nmarp');
  8.  
  9. $query = "SELECT purchasePrice
  10.          FROM code
  11.          WHERE id
  12.          IN (SELECT DISTINCT codeId FROM codeValidationChangelog
  13.          WHERE status = 'Closed: Check Approved')";
  14.  
  15. $result = mysql_query($query);
  16.  
  17. $total = 0;
  18. while ($row = mysql_fetch_array($result)) {
  19.     $row['purchasePrice'] = preg_replace('/[^\d\.]/', '', $row['purchasePrice']);
  20.     $purchasePrice = (float)$row['purchasePrice'];
  21.     $purchasePrice = trim($purchasePrice);
  22.     $purchasePrice = sprintf('%.2f', $purchasePrice);
  23.  
  24.     $total += $purchasePrice;
  25. }
  26. echo $total . PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement