forked from goldentechnologyrec/segma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_authors.php
45 lines (37 loc) · 1.47 KB
/
get_authors.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
require_once("connect.php");
extract($_POST);
$status = $_POST['status'];
$result = pg_query($conn, "SELECT * FROM authors");
$rows = pg_num_rows($result);
$totalCount = pg_num_rows($result);
$search_where = '';
if(!empty($_POST['search']["value"])){
$search_where = "where";
$search_where .= " LOWER(first_name) LIKE '%{$search['value']}%' OR UPPER (first_name) LIKE '%{$search['value']}%'";
$search_where .= " OR LOWER (last_name) LIKE '%{$search['value']}%' OR UPPER (last_name) LIKE '%{$search['value']}%'";
# $search_where .= " OR email LIKE '%{$search['value']}%' ";
}
if($status != ''){
$search_where = "where first_name LIKE '%{$search['value']}%' ";
$search_where .= "and (groupes ='".$status."' ) ";
}
$columns_arr = array("id","first_name","last_name","email","age","groupes");
$query =pg_query($conn, "SELECT * FROM authors $search_where ORDER BY {$columns_arr[$order[0]['column']]} {$order[0]['dir']} limit {$length} offset {$start}");
$r = "SELECT * FROM authors $search_where";
$sql = pg_query($conn,$r);
$recordsFilterCount = pg_num_rows($query);
$recordsTotal= $totalCount;
$recordsFiltered= $recordsFilterCount;
$data = array();
$i= 1 + $start;
while($row = pg_fetch_assoc($query)){
$row['no'] = $i++;
$data[] = $row;
}
echo json_encode(array('draw'=>$draw,
'recordsTotal'=>$recordsTotal,
'recordsFiltered'=>$recordsFiltered,
'data'=>$data,
)
);