 <p>You can just calculate in your query like this:</p> <pre><code>$query = "SELECT (Sqrt(min. Economy) x ( 1 + Sqrt(Distance)/75 + Sqrt(Players)/10 ) Sqrt(88) x ( 1 + Sqrt(23)/75 + Sqrt(23)/10 ) = 15 cred./h) as `Distance`, * FROM routes ORDER BY id DESC LIMIT 8;"; </code></pre> <p>Use as for naming your calculation so its become a column and use * to get the other fields.</p>