ok
Direktori : /home2/selectio/www/caliberembedded.com/admin/api/ |
Current File : //home2/selectio/www/caliberembedded.com/admin/api/user-data-table.php |
<?php include"../config/config.php"; $requestData= $_REQUEST; /*Fetch Database column Details*/ $columns = array( 0 =>'id', 1 =>'name', 1 =>'email', 1 =>'phone', 1 =>'address', 1 =>'massage', ); $conditions=""; /*Fetch All Data Start*/ $statement = $pdo->prepare("SELECT * FROM tbl_user e where e.status!=0 ".$conditions." ORDER BY e.id DESC"); $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $totalData = $statement->rowCount(); $totalFiltered = $totalData; /*Fetch All Data End*/ /*Fetch Filter Data Start*/ $sql="SELECT * FROM tbl_user e where e.status!=0 ".$conditions; if( !empty($_REQUEST['search']) ) { $sql.=" AND ( e.name LIKE '%".$_REQUEST['search']."%') "; $sql.=" AND ( e.phone LIKE '%".$_REQUEST['search']."%') "; $sql.=" AND ( e.email LIKE '%".$_REQUEST['search']."%') "; $sql.=" AND ( e.address LIKE '%".$_REQUEST['search']."%') "; $sql.=" AND ( e.message LIKE '%".$_REQUEST['search']."%') "; } /*Fetch Filter Data End*/ $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; $statement = $pdo->prepare($sql); $statement->execute(); $query = $statement->fetchAll(PDO::FETCH_ASSOC); $data = array(); $i=1; foreach( $query as $row ) { // preparing an array $nestedData=array(); $nestedData[] = "<div class='text-center'><div class='btn-group'> <a style='padding: 6px;margin-right: 3px;' href='user-edit.php?id=".$row["id"]."' title='Edit Description' class='tip btn btn-warning btn-xs'> <i class='fa fa-edit'></i> </a> <button style='padding: 6px;margin-right: 3px;' value='11' title='Delete User' onClick='delete_user(".$row["id"].")' class='tip btn btn-danger btn-xs'> <i class='fa fa-trash-o'></i> </button> </div></div>"; $nestedData[] = $i; $nestedData[] = $row["name"]; $nestedData[] = $row["email"]; $nestedData[] = $row["phone"]; $nestedData[] = $row["address"]; $nestedData[] = $row["message"]; $data[] = $nestedData; $i++; } $json_data = array( "draw" => intval( $requestData['draw'] ), "recordsTotal" => intval( $totalData ), "recordsFiltered" => intval( $totalFiltered ), "data" => $data ); echo json_encode($json_data); ?>