i can't search in datatables
i can't search in datatables
I have a problem, im can't search in datatables
I use join table in serverside
my script :
```
<?php
session_start();
$sesi_username = isset($_SESSION['username']) ? $_SESSION['username'] : NULL;
$sesi_level = isset($_SESSION['leveluser']) ? $_SESSION['leveluser'] : NULL;
if ($sesi_level !='1'){
header('location:../index.php');
}
mb_internal_encoding('UTF-8');
$aColumns = array( 'id_absensi','nip','nama','tanggal_absen','shift','jam_in','jam_out','status_masuk','status_keluar','terlambat','pulangcepat','ket' );
$aColumns2 = array( 'id_absensi','absensi.nip AS nip','b.nama AS nama','tanggal_absen','c.shift AS shift','jam_in','jam_out','status_masuk','status_keluar','terlambat','pulangcepat','ket' );
$sIndexColumn = 'id_absensi';
$sTable = 'absensi';
$sJoin = ' LEFT JOIN pegawai b ON absensi.nip = b.nip';
$sJoin .= ' LEFT JOIN tbl_absen c ON absensi.id_abs = c.id_abs';
$input =& $_POST;
$gaSql['charset'] = 'utf8';
include "../config/koneksi.php";
$sLimit = "";
if ( isset( $input['iDisplayStart'] ) && $input['iDisplayLength'] != '-1' ) {
$sLimit = " LIMIT ".intval( $input['iDisplayStart'] ).", ".intval( $input['iDisplayLength'] );
}
$aOrderingRules = array();
if ( isset( $input['iSortCol_0'] ) ) {
$iSortingCols = intval( $input['iSortingCols'] );
for ( $i=0 ; $i<$iSortingCols ; $i++ ) {
if ( $input[ 'bSortable_'.intval($input['iSortCol_'.$i]) ] == 'true' ) {
$aOrderingRules[] =
"`".$aColumns[ intval( $input['iSortCol_'.$i] ) ]."` "
.($input['sSortDir_'.$i]==='asc' ? 'asc' : 'desc');
}
}
}
if (!empty($aOrderingRules)) {
$sOrder = " ORDER BY ".implode(", ", $aOrderingRules);
} else {
$sOrder = "";
}
$iColumnCount = count($aColumns);
if ( isset($input['sSearch']) && $input['sSearch'] != "" ) {
$aFilteringRules = array();
for ( $i=0 ; $i<$iColumnCount ; $i++ ) {
if ( isset($input['bSearchable_'.$i]) && $input['bSearchable_'.$i] == 'true' ) {
$aFilteringRules[] = "`".$aColumns[$i]."` LIKE '%".$mysqli->real_escape_string( $input['sSearch'] )."%'";
}
}
if (!empty($aFilteringRules)) {
$aFilteringRules = array('('.implode(" OR ", $aFilteringRules).')');
}
}
// Individual column filtering
for ( $i=0 ; $i<$iColumnCount ; $i++ ) {
if ( isset($input['bSearchable_'.$i]) && $input['bSearchable_'.$i] == 'true' && $input['sSearch_'.$i] != '' ) {
$aFilteringRules[] = "`".$aColumns[$i]."` LIKE '%".$mysqli->real_escape_string($input['sSearch_'.$i])."%'";
}
}
if (!empty($aFilteringRules)) {
$sWhere = " WHERE ".implode(" AND ", $aFilteringRules);
} else {
$sWhere = "";
}
$aQueryColumns = array();
foreach ($aColumns as $col) {
if ($col != ' ') {
$aQueryColumns[] = $col;
}
}
/*
* SQL queries
* Get data to display
*/
$sQuery = "
SELECT SQL_CALC_FOUND_ROWS " . str_replace(" , ", " ", implode(", ", $aColumns2)) . "
FROM $sTable
$sJoin
$sWhere
$sOrder
$sLimit
";
$rResult = $mysqli->query( $sQuery ) or die($mysqli->error);
$sQuery = "SELECT FOUND_ROWS()";
$rResultFilterTotal = $mysqli->query( $sQuery ) or die($mysqli->error);
list($iFilteredTotal) = $rResultFilterTotal->fetch_row();
$sQuery = "SELECT COUNT(`".$sIndexColumn."`) FROM `".$sTable."`";
$rResultTotal = $mysqli->query( $sQuery ) or die($mysqli->error);
list($iTotal) = $rResultTotal->fetch_row();
$output = array(
"sEcho" => intval($input['sEcho']),
"iTotalRecords" => $iTotal,
"iTotalDisplayRecords" => $iFilteredTotal,
"aaData" => array(),
);
while ( $aRow = $rResult->fetch_assoc() ) {
$row = array();
for ( $i=0 ; $i<$iColumnCount ; $i++ ) {
$row[] = $aRow[ $aColumns[$i] ];
}
$row = array( $aRow['nip'],
$aRow['nama'],
$aRow['tanggal_absen'],
$aRow['shift'],
$aRow['jam_in'],
$aRow['jam_out'],
$aRow['status_masuk'],
$aRow['status_keluar'],
$aRow['terlambat'],
$aRow['pulangcepat'],
$aRow['ket']
);
$output['aaData'][] = $row;
}
echo json_encode($output);
<?php
>
```
?>
Answers
pleasee help me
help me