diff --git a/DonationsStats.php b/DonationsStats.php
index aa9365b..9da1770 100755
--- a/DonationsStats.php
+++ b/DonationsStats.php
@@ -14,34 +14,46 @@ $total_ever = 0.0;
function print_donation_year($year) {
-if (! $db_link) {
- return;
-}
-
$amount = 0.0;
$max_month = 0.0;
$total_year = 0.0;
-$sql_donations = mysql_query("SELECT * FROM donations WHERE YEAR(dt) = " . $year);
-
-if (mysql_num_rows($sql_donations)) {
- while ($sql_row = mysql_fetch_assoc($sql_donations)) {
- $amount = $sql_row["amount"]
- if ($amount > $max_month) {
- $max_month = $amount;
- if ($amount > $biggest_donation_value) {
- $biggest_donation_date = date("Y-m-d", strtotime($sql_row["dt"]));
- $biggest_donation_value = $amount;
+$donation_count = 0.0;
+
+if ($db_link) {
+ $sql_donations = mysql_query("SELECT * FROM donations WHERE YEAR(dt) = " . $year);
+
+ if (mysql_num_rows($sql_donations)) {
+ while ($sql_row = mysql_fetch_assoc($sql_donations)) {
+ $amount = $sql_row["amount"];
+ $donation_count += 1.0;
+ if ($amount > $max_month) {
+ $max_month = $amount;
+ if ($amount > $biggest_donation_value) {
+ $biggest_donation_date = date("Y-m-d", strtotime($sql_row["dt"]));
+ $biggest_donation_value = $amount;
+ }
}
+ $total_year += $amount;
}
- $total_year += $amount;
- }
+ }
}
$total_ever += $total_year;
-echo '
' . $year . ' | ' . ($total_year/12.0) . '€ | ' . $max_month . '€ |
';
+echo '';
+echo ' ' . $year . ' | ';
+echo ' ' . $donation_count . ' | ';
+echo ' ' . $total_year . '€ | ';
+if ($donation_count > 0.0) {
+ echo ' ' . ($total_year/$donation_count) . '€ | ';
+} else {
+ echo ' 0€ | ';
+}
+echo ' ' . ($total_year/12.0) . '€ | ';
+echo ' ' . $max_month . '€ | ';
+echo '
';
}
@@ -60,8 +72,16 @@ echo '' . $year . ' | ' . ($total_year/12.0) . '€ | ' .
Thank you very much for your generosity!
-
-Year> | Total | Average per month | Biggest single donation |
+
+
+
+ Year |
+ Donations count |
+ Total received |
+ Average per donation |
+ Average per month |
+ Biggest single donation |
+
= "2014"; $year -= 1) {
@@ -70,6 +90,7 @@ for ($year = strftime("%Y"); $year >= "2014"; $year -= 1) {
?>
+
|