나는 그러나 아무도누적 합계를 계산하는 방법은 무엇입니까?
을 충족하지 PHP 총 질문을 실행 (많은 폐쇄) 다른 살펴 보았다 난 다음 내가 얻을 루프를 완료 쿼리의 결과를 에코 경우이 내 쿼리
<?php
$query = "SELECT SUM(game_total) AS totalgames,
SUM(goals) AS totalgoals,
FROM player
WHERE year between 2006 and 2013
AND month between 1 and 12
GROUP BY
year,
month between 1 and 3,
month between 4 and 6,
month between 7 and 9,
month between 10 and 12
ORDER BY year ASC, month ASC";
$rquery = mysql_query($query) or die(mysql_error());
$show2 = '';
while ($row = mysql_fetch_array($rquery)){
$games = $row['totalgames'];
$goals = $row['totalgoals'];
$gpg = $games == 0 ? 0 : number_format($goals/$games,2);
}
?>
입니다 결과
+---------+----------+-----------+
| Goals | Games | GPG |
+---------+----------+-----------+
| 8 | 15 | 0.53 |
+---------+----------+-----------+
| 2 | 12 | 0.17 |
+---------+----------+-----------+
| 2 | 12 | 0.17 |
+---------+----------+-----------+
| 13 | 21 | 0.62 |
+---------+----------+-----------+
등
그러나, 나는 다음과 같은 방식으로 실행 GPG를 계산할 등
Goals/Games=GPG
8/15=0.53
10/27=0.37 (8+2/15+12)=GPG
12/39=0.31 (10+2/27+12)=GPG
25/60=0.41 (12+13/39+21)=GPG
내가처럼 반향 할이
0.53,0.37,0.31,0.41 등 등
어떻게 이런 짓을 했을까?
코더에 작동하지 않는 항목이 있습니까? –
무엇을 의미합니까? –
질문에 귀사가 원하는 결과를 얻었음을 보여 주므로 귀하의 질문이 확실하지 않은 것입니까? 이 코드에서 작동하지 않는 것이 있습니까? –