Changeset View
Changeset View
Standalone View
Standalone View
fundraisers/randameetings2017/index.php
Show All 24 Lines | 23 | <?php | |||
---|---|---|---|---|---|
25 | 25 | | |||
26 | $goal_fmt=number_format(20000); | 26 | $goal_fmt=number_format(20000); | ||
27 | $goal=20000; | 27 | $goal=20000; | ||
28 | $enddate="2017-09-30"; | 28 | $enddate="2017-09-30"; | ||
29 | $daystogo=floor((strtotime($enddate)-time())/(60*60*24)); | 29 | $daystogo=floor((strtotime($enddate)-time())/(60*60*24)); | ||
30 | 30 | | |||
31 | require_once("config.php"); | 31 | require_once("config.php"); | ||
32 | 32 | | |||
33 | $stmt = $dbConnection->prepare("SELECT *, UNIX_TIMESTAMP(CREATED_AT) AS date_t FROM randameetings2017donations ORDER BY CREATED_AT DESC;") or die ($dbConnection->error); | 33 | $countStmt = $dbConnection->prepare("SELECT COUNT(*) FROM randameetings2017donations ORDER BY CREATED_AT DESC;"); | ||
34 | $stmt->execute(); | 34 | $countStmt->execute(); | ||
35 | $result = $stmt->get_result(); | 35 | $n = $countStmt->fetchColumn(); | ||
36 | $stmt->close(); | 36 | | ||
37 | $res = $dbConnection->prepare("SELECT *, UNIX_TIMESTAMP(CREATED_AT) AS date_t FROM randameetings2017donations ORDER BY CREATED_AT DESC;"); | ||||
38 | $res->execute(); | ||||
37 | $total = 0; | 39 | $total = 0; | ||
38 | $count = $result->num_rows; | 40 | $count = $n; | ||
39 | $n = $count; | 41 | $n = $count; | ||
40 | $table = ""; | 42 | $table = ""; | ||
41 | while ($row = mysqli_fetch_array($result)) { | 43 | while ($row = $res->fetch()) { | ||
42 | $name = htmlspecialchars($row["donor_name"]); | 44 | $name = htmlspecialchars($row["donor_name"]); | ||
43 | if ($name == "") | 45 | if ($name == "") | ||
44 | $name = "<i>Anonymous donation</i>"; | 46 | $name = "<i>Anonymous donation</i>"; | ||
45 | $total += $row["amount"]; | 47 | $total += $row["amount"]; | ||
46 | 48 | | |||
47 | $table.="<tr>"; | 49 | $table.="<tr>"; | ||
48 | $table.="<td>".$n."</td>"; | 50 | $table.="<td>".$n."</td>"; | ||
49 | $table.="<td>".date("jS F Y", $row["date_t"])."</td>"; | 51 | $table.="<td>".date("jS F Y", $row["date_t"])."</td>"; | ||
50 | $table.="<td>€".number_format($row["amount"],2)."</td>"; | 52 | $table.="<td>€".number_format($row["amount"],2)."</td>"; | ||
51 | $table.="<td>".$name."</td>"; | 53 | $table.="<td>".$name."</td>"; | ||
52 | $table.="</tr>"; | 54 | $table.="</tr>"; | ||
53 | $n--; | 55 | $n--; | ||
54 | } | 56 | } | ||
55 | $table.=""; | 57 | $table.=""; | ||
56 | mysqli_close($dbConnection); | 58 | $dbConnection = null; | ||
57 | $percent=round($total * 100 / $goal); | 59 | $percent=round($total * 100 / $goal); | ||
58 | $percent=min($percent, 100); | 60 | $percent=min($percent, 100); | ||
59 | $graph_style = "width: 100%; height: 30px; border: 1px solid #888; background: rgb(204,204,204); | 61 | $graph_style = "width: 100%; height: 30px; border: 1px solid #888; background: rgb(204,204,204); | ||
60 | position: relative;"; | 62 | position: relative;"; | ||
61 | $bar_style = "height: 30px; background: rgb(68,132,242); width: ".$percent."%"; | 63 | $bar_style = "height: 30px; background: rgb(68,132,242); width: ".$percent."%"; | ||
62 | ?> | 64 | ?> | ||
63 | 65 | | |||
64 | <div id="wrapper"> | 66 | <div id="wrapper"> | ||
▲ Show 20 Lines • Show All 615 Lines • Show Last 20 Lines |