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,24 +1,22 @@
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
|
||||||
<div class="container-fluid">
|
<!-- Breadcrumbs-->
|
||||||
|
<ol class="breadcrumb">
|
||||||
<!-- Breadcrumbs-->
|
<li class="breadcrumb-item">
|
||||||
<ol class="breadcrumb">
|
<a href="index.html">Dashboard</a>
|
||||||
<li class="breadcrumb-item">
|
</li>
|
||||||
<a href="index.html">Dashboard</a>
|
<li class="breadcrumb-item active">404 Error</li>
|
||||||
</li>
|
</ol>
|
||||||
<li class="breadcrumb-item active">404 Error</li>
|
|
||||||
</ol>
|
<!-- Page Content -->
|
||||||
|
<h1 class="display-1">404</h1>
|
||||||
<!-- Page Content -->
|
<p class="lead">Page not found. You can
|
||||||
<h1 class="display-1">404</h1>
|
<a href="javascript:history.back()">go back</a>
|
||||||
<p class="lead">Page not found. You can
|
to the previous page, or
|
||||||
<a href="javascript:history.back()">go back</a>
|
<a href="index.html">return home</a>.</p>
|
||||||
to the previous page, or
|
|
||||||
<a href="index.html">return home</a>.</p>
|
</div>
|
||||||
|
<!-- /.container-fluid -->
|
||||||
</div>
|
|
||||||
<!-- /.container-fluid -->
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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