Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Exclude inactive people unless requesting all of them

  • Loading branch information...
commit 44ccb174875c8b0c7530635472fa1e2695a6000b 1 parent eeb817f
@jimwins authored
Showing with 7 additions and 1 deletion.
  1. +3 −0  api/person-list.php
  2. +4 −1 person.php
View
3  api/person-list.php
@@ -12,6 +12,9 @@
OR person.company LIKE '%$term%')";
}
+if (!$_REQUEST['all'])
+ $criteria[]= 'active';
+
if (empty($criteria)) {
$criteria= '1=1';
} else {
View
5 person.php
@@ -10,6 +10,7 @@
?>
<form method="get" action="person.php">
<input id="focus" type="text" name="search" value="<?=ashtml($search)?>">
+<label><input type="checkbox" value="1" name="all"<?=$_REQUEST['all']?' checked="checked"':''?>> All</label>
<input type="submit" value="Find People">
</form>
<br>
@@ -18,13 +19,15 @@
if (!empty($search)) {
$search= $db->real_escape_string($search);
+ $active= $_REQUEST['all'] ? "" : 'AND active';
+
$q= "SELECT IF(deleted, 'deleted', '') AS meta,
CONCAT(id, '|', IFNULL(company,''),
'|', IFNULL(name,''))
AS Person\$person
FROM person
WHERE (name like '%$search%' OR company LIKE '%$search%')
- AND active
+ $active
ORDER BY company, name";
$r= $db->query($q)
Please sign in to comment.
Something went wrong with that request. Please try again.