-
Notifications
You must be signed in to change notification settings - Fork 1
/
personsearch.php
21 lines (21 loc) · 912 Bytes
/
personsearch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
include '../../core/inc.php';
include 'db/cognizdb.php';
function find_person_like($name,$db){
$pql = $db->prepare("SELECT * FROM persons WHERE name LIKE :value AND display='1' ORDER BY id ASC");
$pql->bindValue(':value', "%$name%", PDO::PARAM_STR);
$pql->execute();
$v = $pql->fetchAll(PDO::FETCH_ASSOC);
return $v;
}
$q = $_GET['q'] ?? '';
$matches = find_person_like($q,$cdb);
if($matches){
foreach ($matches as $m){
echo '<span style="display: block; margin-bottom: 0.8em">'.$m['name'].' ('.$m['ins'].') <br /><a onclick="acceptCurrent(\''.$m['id'].'\',\''.addslashes($m['name']).'\')" href="#">Current member</a> || <a onclick="acceptPrevious(\''.$m['id'].'\',\''.addslashes($m['name']).'\')" href="#">Previous member</a></span>'."\n";
}
}
else {
echo '<label>List instruments/voice here <input type="text" id="ins" /></label> <input type="button" onclick="addToDb()" value="add person" />'."\n";
}
?>