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(){
|
||||
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();
|
||||
while ($row = $res->fetch_assoc()) {
|
||||
$ret[] = $row;
|
||||
|
@ -32,7 +32,7 @@ function get_founditems(){
|
|||
|
||||
function get_lostitems(){
|
||||
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();
|
||||
while ($row = $res->fetch_assoc()) {
|
||||
$ret[] = $row;
|
||||
|
@ -68,6 +68,7 @@ function get_stats(){
|
|||
if ($row = $res->fetch_assoc()) {
|
||||
$ret["match"] = $row["c"];
|
||||
}
|
||||
$ret["unmatched"] = $ret["found"] + $ret["lost"] - (2 * $ret["match"]);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<!-- Breadcrumbs-->
|
||||
|
|
|
@ -75,7 +75,7 @@ $stats = get_stats();
|
|||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-comments"></i>
|
||||
</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>
|
||||
<a class="card-footer text-white clearfix small z-1" href="/?page=tinder">
|
||||
<span class="float-left">View Details</span>
|
||||
|
|
Loading…
Reference in a new issue