From df739247a111bcfe39ac382a64d036ce45145895 Mon Sep 17 00:00:00 2001 From: /jedi/ Date: Fri, 22 Feb 2019 13:53:53 +0100 Subject: [PATCH] fix diagram data query --- index.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index 8b12eb6..b26617c 100644 --- a/index.php +++ b/index.php @@ -79,21 +79,21 @@ function get_stats(){ - $res = $mysqli->query("select hour(date) as h, day(date) as d, count(date) as c from items group by h, d order by d, h"); + $res = $mysqli->query("select hour(date) as h, day(date) as d, count(date) as c from found_items group by h, d order by d, h"); $ret["graph"] = array(); - while ($row = $res->fetch_assoc()) { + while ($res && $row = $res->fetch_assoc()) { $ret["graph"][] = $row; } $res = $mysqli->query("SELECT COUNT(*) AS c FROM lost_items WHERE lost_items.del = 0 ORDER BY id ASC"); - if ($row = $res->fetch_assoc()) { + if ($res && $row = $res->fetch_assoc()) { $ret["lost"] = $row["c"]; } $res = $mysqli->query("SELECT COUNT(*) AS c FROM found_items WHERE found_items.del = 0 ORDER BY id ASC"); - if ($row = $res->fetch_assoc()) { + if ($res && $row = $res->fetch_assoc()) { $ret["found"] = $row["c"]; } $res = $mysqli->query("SELECT COUNT(*) AS c FROM matches ORDER BY id ASC"); - if ($row = $res->fetch_assoc()) { + if ($res && $row = $res->fetch_assoc()) { $ret["match"] = $row["c"]; } $ret["unmatched"] = $ret["found"] + $ret["lost"] - 2 * $ret["match"];