$sql = "SELECT * FROM `bank_note` JOIN u_admin ON u_admin.id_u_admin=bank_note.id_u_admin JOIN bank_owner on bank_owner.id_ow=bank_note.id_ow JOIN type_bank on type_bank.id_type_b=bank_owner.id_type_b ";
if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter
$sql.=" AND ( DATE_FORMAT(ad_time_bank, '%Y-%m-%d') like '".$requestData['search']['value']."%' ";
$sql.=" OR user_admin LIKE '".$requestData['search']['value']."%' ";
$sql.=" OR name_type_b LIKE '".$requestData['search']['value']."%' ";
$sql.=" OR b_ow LIKE '".$requestData['search']['value']."%' ";
$sql.=" OR money_ad LIKE '".$requestData['search']['value']."%' ";
$sql.=" OR note LIKE '".$requestData['search']['value']."%' )";
}
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees 2");
$totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result.
$sql.=" ORDER BY `bank_note`.`ad_time_bank` DESC LIMIT ".$requestData['start']." ,".$requestData['length']." ";
/* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc */
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees 3");
$data = array();
while( $row=mysqli_fetch_array($query) ) { // preparing an array
$nestedData=array();
$nestedData[] = $row["ad_time_bank"];
$nestedData[] = $row["user_admin"];
$nestedData[] = $row["name_type_b"];
$nestedData[] = $row["b_ow"];
$nestedData[] = $row["money_ad"];
$nestedData[] = $row["note"];
$data[] = $nestedData;
}
$sql = "SELECT * FROM `bank_note` JOIN u_admin ON u_admin.id_u_admin=bank_note.id_u_admin JOIN bank_owner on bank_owner.id_ow=bank_note.id_ow JOIN type_bank on type_bank.id_type_b=bank_owner.id_type_b ";
if( !empty($requestData['search']['value']) ) { // if there is a search parameter, $requestData['search']['value'] contains search parameter
$sql.=" AND ( DATE_FORMAT(ad_time_bank, '%Y-%m-%d') like '".$requestData['search']['value']."%' ";
$sql.=" OR user_admin LIKE '".$requestData['search']['value']."%' ";
$sql.=" OR name_type_b LIKE '".$requestData['search']['value']."%' ";
$sql.=" OR b_ow LIKE '".$requestData['search']['value']."%' ";
$sql.=" OR money_ad LIKE '".$requestData['search']['value']."%' ";
$sql.=" OR note LIKE '".$requestData['search']['value']."%' )";
}
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees 2");
$totalFiltered = mysqli_num_rows($query); // when there is a search parameter then we have to modify total number filtered rows as per search result.
$sql.=" ORDER BY `bank_note`.`ad_time_bank` DESC LIMIT ".$requestData['start']." ,".$requestData['length']." ";
/* $requestData['order'][0]['column'] contains colmun index, $requestData['order'][0]['dir'] contains order such as asc/desc */
$query=mysqli_query($conn, $sql) or die("employee-grid-data.php: get employees 3");
$data = array();
while( $row=mysqli_fetch_array($query) ) { // preparing an array
$nestedData=array();
function DateThai($strDate)
{
$strYear = date("Y",strtotime($strDate))+543;
$strMonth= date("n",strtotime($strDate));
$strDay= date("j",strtotime($strDate));
$strHour= date("H",strtotime($strDate));
$strMinute= date("i",strtotime($strDate));
$strSeconds= date("s",strtotime($strDate));
$strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
$strMonthThai=$strMonthCut[$strMonth];
return "$strDay $strMonthThai $strYear, $strHour:$strMinute";
}
$strDate = $row["ad_time_bank"];
$date = DateThai($strDate);
$nestedData[] = $date;
$nestedData[] = $row["user_admin"];
$nestedData[] = $row["name_type_b"];
$nestedData[] = $row["b_ow"];
$nestedData[] = $row["money_ad"];
$nestedData[] = $row["note"];
$data[] = $nestedData;
}