I am trying to run a sum from numbers taken from a database. However i can't seem to get it to work.
Does anyone have any ideas as to why i keep getting 0 instead of a percentage? if so could you guide me in the right direction.
PHP:
//SQL Original Goal
$goal = "SELECT * FROM login WHERE username = '$login'";
$goalquery = mysql_query($goal);
$goalarray = mysql_fetch_array($goalquery);
$endgoal = $goalarray['goal'];
//Latest Weight
$latestweightarray = mysql_fetch_array($latestweightq);
$currentweight = $latestweightarray['weight'];
//First Weight Recorded
$firstweightarray = mysql_fetch_array($firstweightq);
$firstweight = $firstweightarray['weight'];
$percent = "100";
$progress = (($firstweight - $currentweight) / ($firstweight - $endgoal)) * $percent;
Print Result:
<?php
echo $progress
?>
This just gives: 0