agregar filtro por un campo a getallrecord
Publicado por pedru (2 intervenciones) el 04/01/2021 10:20:02
quisiera agregar filtro po un campo en getallrecord
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
$condition = '';
if(isset($_REQUEST['username']) and $_REQUEST['username']!=""){
$condition .= ' AND username LIKE "%'.$_REQUEST['username'].'%" ';
}
if(isset($_REQUEST['useremail']) and $_REQUEST['useremail']!=""){
$condition .= ' AND useremail LIKE "%'.$_REQUEST['useremail'].'%" ';
}
if(isset($_REQUEST['fechafact']) and $_REQUEST['fechafact']!=""){
$condition .= ' AND fechafact LIKE "%'.$_REQUEST['fechafact'].'%" ';
}
if(isset($_REQUEST['montofact']) and $_REQUEST['montofact']!=""){
$condition .= ' AND montofact LIKE "%'.$_REQUEST['montofact'].'%" ';
}
if(isset($_REQUEST['df']) and $_REQUEST['df']!=""){
$condition .= ' AND DATE(dt)>="'.$_REQUEST['df'].'" ';
}
if(isset($_REQUEST['dt']) and $_REQUEST['dt']!=""){
$condition .= ' AND DATE(dt)<="'.$_REQUEST['dt'].'" ';
}
// $this->db-> like ('nombre', 'pedro'); esto me funcionó pero despues me dio errpr o filtre por la sesion $_SESSION['username']
$userData = $db->getAllRecords('users','*' ,$condition,'ORDER BY id DESC');
Valora esta pregunta


0