Changeset View
Changeset View
Standalone View
Standalone View
fundraisers/yearend2017/index.php
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 80 | <li class="page-section__paragraph"> | |||
---|---|---|---|---|---|
83 | </p> | 83 | </p> | ||
84 | </li> | 84 | </li> | ||
85 | </ul> | 85 | </ul> | ||
86 | </div> | 86 | </div> | ||
87 | <!-- End of Introduction --> | 87 | <!-- End of Introduction --> | ||
88 | <?php | 88 | <?php | ||
89 | require_once("config.php"); | 89 | require_once("config.php"); | ||
90 | 90 | | |||
91 | $stmt = $dbConnection->prepare("SELECT *, UNIX_TIMESTAMP(CREATED_AT) AS date_t FROM endofyear2017donations ORDER BY CREATED_AT DESC;") or die($dbConnection->error); | 91 | $countStmt = $dbConnection->prepare("SELECT COUNT(*) FROM endofyear2017donations ORDER BY CREATED_AT DESC;"); | ||
92 | $stmt->execute(); | 92 | $countStmt->execute(); | ||
93 | $result = $stmt->get_result(); | 93 | $n = $countStmt->fetchColumn(); | ||
94 | $stmt->close(); | 94 | | ||
95 | $count = $result->num_rows; | 95 | $res = $dbConnection->prepare("SELECT *, UNIX_TIMESTAMP(CREATED_AT) AS date_t FROM endofyear2017donations ORDER BY CREATED_AT DESC;"); | ||
96 | ?> | 96 | $res->execute(); | ||
97 | <?php | | |||
98 | $total = 0; | 97 | $total = 0; | ||
99 | $n = $count; | | |||
100 | $table = ""; | 98 | $table = ""; | ||
101 | while ($row = mysqli_fetch_array($result)) { | 99 | while ($row = $res->fetch()) { | ||
102 | $name = htmlspecialchars($row["donor_name"]); | 100 | $name = htmlspecialchars($row["donor_name"]); | ||
103 | if ($name == "") { | 101 | if ($name == "") { | ||
104 | $name = "<i>Anonymous donation</i>"; | 102 | $name = "<i>Anonymous donation</i>"; | ||
105 | } | 103 | } | ||
106 | $total += $row["amount"]; | 104 | $total += $row["amount"]; | ||
107 | 105 | | |||
108 | $table.="<tr>"; | 106 | $table.="<tr>"; | ||
109 | $table.="<td>".$n."</td>"; | 107 | $table.="<td>".$n."</td>"; | ||
110 | $table.="<td>".date("jS F Y", $row["date_t"])."</td>"; | 108 | $table.="<td>".date("jS F Y", $row["date_t"])."</td>"; | ||
111 | $table.="<td>€".number_format($row["amount"], 2)."</td>"; | 109 | $table.="<td>€".number_format($row["amount"], 2)."</td>"; | ||
112 | $table.="<td>".$name."</td>"; | 110 | $table.="<td>".$name."</td>"; | ||
113 | $table.="</tr>"; | 111 | $table.="</tr>"; | ||
114 | $n--; | 112 | $n--; | ||
115 | } | 113 | } | ||
116 | $table.=""; | 114 | $dbConnection = null; | ||
117 | mysqli_close($dbConnection); | | |||
118 | $goal_fmt=number_format(20000); | 115 | $goal_fmt=number_format(20000); | ||
119 | $goal=20000; | 116 | $goal=20000; | ||
120 | $percent=round($total * 100 / $goal); | 117 | $percent=round($total * 100 / $goal); | ||
121 | $percent=min($percent, 100); | 118 | $percent=min($percent, 100); | ||
122 | ?> | 119 | ?> | ||
123 | <div class="text-center "> | 120 | <div class="text-center "> | ||
124 | <h2 class="page-section__title ">Status</h2> | 121 | <h2 class="page-section__title ">Status</h2> | ||
125 | </div> | 122 | </div> | ||
▲ Show 20 Lines • Show All 251 Lines • Show Last 20 Lines |