add left join
This commit is contained in:
parent
aaff9d65be
commit
fecc2fffcd
3 changed files with 24 additions and 25 deletions
|
@ -22,7 +22,7 @@ function auth(){
|
||||||
|
|
||||||
function get_founditems(){
|
function get_founditems(){
|
||||||
global $mysqli;
|
global $mysqli;
|
||||||
$res = $mysqli->query("SELECT * FROM items ORDER BY id ASC");
|
$res = $mysqli->query("SELECT * FROM items LEFT JOIN matches ON items.id = matches.f_id WHERE matches.f_id IS NULL ORDER BY id ASC");
|
||||||
$ret = array();
|
$ret = array();
|
||||||
while ($row = $res->fetch_assoc()) {
|
while ($row = $res->fetch_assoc()) {
|
||||||
$ret[] = $row;
|
$ret[] = $row;
|
||||||
|
@ -32,7 +32,7 @@ function get_founditems(){
|
||||||
|
|
||||||
function get_lostitems(){
|
function get_lostitems(){
|
||||||
global $mysqli;
|
global $mysqli;
|
||||||
$res = $mysqli->query("SELECT * FROM lost ORDER BY id ASC");
|
$res = $mysqli->query("SELECT * FROM lost LEFT JOIN matches ON lost.id = matches.l_id WHERE matches.l_id IS NULL ORDER BY id ASC");
|
||||||
$ret = array();
|
$ret = array();
|
||||||
while ($row = $res->fetch_assoc()) {
|
while ($row = $res->fetch_assoc()) {
|
||||||
$ret[] = $row;
|
$ret[] = $row;
|
||||||
|
@ -68,6 +68,7 @@ function get_stats(){
|
||||||
if ($row = $res->fetch_assoc()) {
|
if ($row = $res->fetch_assoc()) {
|
||||||
$ret["match"] = $row["c"];
|
$ret["match"] = $row["c"];
|
||||||
}
|
}
|
||||||
|
$ret["unmatched"] = $ret["found"] + $ret["lost"] - (2 * $ret["match"]);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
|
|
||||||
<!-- Breadcrumbs-->
|
<!-- Breadcrumbs-->
|
||||||
|
|
|
@ -75,7 +75,7 @@ $stats = get_stats();
|
||||||
<div class="card-body-icon">
|
<div class="card-body-icon">
|
||||||
<i class="fas fa-fw fa-comments"></i>
|
<i class="fas fa-fw fa-comments"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="mr-5"><?php echo $stats["lost"]+$stats["found"]-2*$stats["matched"]; ?> Unmatched Items</div>
|
<div class="mr-5"><?php echo $stats["unmatched"]; ?> Unmatched Items</div>
|
||||||
</div>
|
</div>
|
||||||
<a class="card-footer text-white clearfix small z-1" href="/?page=tinder">
|
<a class="card-footer text-white clearfix small z-1" href="/?page=tinder">
|
||||||
<span class="float-left">View Details</span>
|
<span class="float-left">View Details</span>
|
||||||
|
|
Loading…
Reference in a new issue