I am trying to make a sumatory of 2 diferent colums in a data base... then divide this two results in one variable (yeah, i know maybe this is the most stupid question in the whole world ) The story is that im getting a good result when i'm making a sumatory or substraction with this tu variables, but when im trying to make a multiplication or division it returns me a wrong number... very close actually, but not good... here is my code...
Code: Select all
<?php
$con = mysql_connect("localhost","server_name","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("server_name", $con);
$activos = mysql_query("SELECT suma FROM ausentismo");
$total = mysql_num_rows($activos);
echo $total. " de 20";
$result = mysql_query("SELECT sum(suma / multiplicacion) as record FROM ausentismo");
if (!$result) {
die('Invalid query: ' . mysql_error());
}
while ($row = mysql_fetch_array($result)) {
echo "<p>" . $row['record'] . "</p>";
}
?>