我正在尝试从数据库中获取的数字运行总和。但是我似乎无法让它发挥作用。
有没有人有任何想法为什么我一直得到0而不是百分比?如果可以的话,你可以指导我朝正确的方向发展。
PHP:
INSERT INTO yourTable (var1, var2 etc etc) VALUES ('val1', 'val2' etc etc);
SET @last_id = LAST_INSERT_ID();
INSERT INTO yourTable2 (id, var1, var2) VALUES (@last_id, 'blah', 'blah');
打印结果:
//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;
这只是给出:0
答案 0 :(得分:-1)
Rookie Error,我在一天内更新了数据库两次,结果与某些方面发生冲突,改变了数据库中的一个日期,这就解决了问题