Hello,
I need this value for additional mathematical operation, but $sumtot is storing the value as string, hence I have to convert it into double.PHP Code:$getsum1 = @mysql_query('select sum(product) as summ from tempo'); // calculating sum of values in a column named product
$row = mysql_fetch_array($getsum1); // fetching the result into an array
$sumtot = $row['summ']; // the result, which is number in decimals is returned as a string e.
Instead of
I usePHP Code:$sumtot = $row['summ'];
PHP Code:$sumtot = doubleval($row['summ']);
echo (var_dump($sumtot)); // confirms that $sumtot holds a double value
This query is failing, the fields are not getting updated, what is wrong?PHP Code:$finq = @mysql_query('update tempo set percent = (product*100)/$sumtot'); // using the sumtot to calculate percentage and update the same




Reply With Quote