title: Trying to find an easy way for PHP and Mysql DB to do math (AVG MIN MAX) for PHP5.5
body: <p>I currently have PHP 5.3 and need to upgrade to at least PHP 5.5/5.6. I have a page that post averages for rental properties. For a while i got away with using mysql but when I upgrade, in need to use mysqli. Below is a code I tried writing in PDO.</p>
  
  <pre><code>$hostname = "your_hostname";  
  $username = "your_username";  
  $password = "your_password";
  $db = "database";
  
  $dbh = new PDO("mysql:host=$server;dbname=$db", $user, $pass);  
  
  foreach ($dbh-&gt;query("SELECT MAX(rent) FROM table WHERE PType ='$PType' AND PState = '$state'") as $row) { 
      $SMR = "" . $row['MAX(rent)'] . "";
  }
  </code></pre>
  
  <p>That works in PHP 5.3, but not PHP 5.5/5.6. I have tried changing the <code>$dbh</code> line to this:</p>
  
  <pre><code>$dbh = new PDO("mysqli:host=$server;dbname=$db", $user, $pass); 
  </code></pre>
  
  <p>The error log came up with a driver error. </p>
  
  <p>Is there a better way? </p>