/var/www/(Del)pathways.org.hk/MIS20140127/old20140407/LeaveApplication/list.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
include_once '../include/DBConnect.php';
/* If connection to database, run sql statement. */
//$q = strtolower($_GET["Data"]);
//$q = "l";
if ($_POST) {
    
$q strtolower($_POST['Data']);

    
$query ='(SELECT CONCAT( last_name,  " ", first_name,  "(", ch_name,  ")" ) AS name FROM student WHERE deleted =0 and actived =1 GROUP BY root_id)
                UNION 
            (SELECT CONCAT( last_name,  " ", first_name,  "(", ch_name,  ")" ) AS name FROM staff WHERE deleted =0 and actived =1 GROUP BY root_id)'

    
$result $dbh->prepare($query);
    
$result->execute();
    while (
$ResultSet $result->fetch(PDO::FETCH_ASSOC)) {
        
$Array = array(
//            "last_name" => $ResultSet['last_name'],
//            "first_name" => $ResultSet['first_name'],
//            "ch_name" => $ResultSet['ch_name'],
//            "root_id" => $ResultSet['root_id'],
//            "staff_id" => $ResultSet['staff_id']
             
"staffName" => $ResultSet['name']
        );
        
$Arrays[] = $Array;
    };
}
echo 
json_encode($Arrays);