help with search in date_difference column
help with search in date_difference column
empirerock
Posts: 1Questions: 0Answers: 0
Greetings.
I am not able to search the column that shows the date_difference.
Can anyone help me what's wrong.
Just is not working the search in this column.
I thank anyone who can help.
```
<?php
include_once("connection.php");
$params = $columns = $totalRecords = $data = array();
$params = $_REQUEST;
$columns = array(
0 =>'`u`.`id`',
1 =>'`u`.`data_abertura`',
2 =>'`u`.`data_liberacao`',
3 =>'`u`.`data_montagem`',
4 =>'`u`.`codiks`',
5 => '`u`.`planejador`',
6 => '`u`.`date_difference`',
);
$where = $sqlTot = $sqlRec = "";
if( !empty($params['search']['value']) ) {
$where .=" WHERE ";
$where .=" ( u.data_abertura LIKE '".$params['search']['value']."%' )";
$where .=" OR u.data_liberacao LIKE '".$params['search']['value']."%' ";
$where .=" OR u.data_montagem LIKE '".$params['search']['value']."%' ";
$where .=" OR u.codiks LIKE '".$params['search']['value']."%' ";
$where .=" OR u.planejador LIKE '".$params['search']['value']."%' ";
$where .=" OR u.date_difference LIKE '".$params['search']['value']."%' ";
}
$sql = "SELECT *, DATEDIFF(data_liberacao, data_abertura) AS date_difference FROM `dia` AS `u` INNER JOIN `estf004` AS `ud` ON (`ud`.`codiks` = `u`.`codiks`)";
$sqlTot .= $sql;
$sqlRec .= $sql;
if(isset($where) && $where != '') {
$sqlTot .= $where;
$sqlRec .= $where;
}
$sqlRec .= " ORDER BY ". $columns[$params['order'][0]['column']]." ".$params['order'][0]['dir']." LIMIT ".$params['start']." ,".$params['length']." ";
$queryTot = mysqli_query($conn, $sqlTot) or die("database error:". mysqli_error($conn));
$totalRecords = mysqli_num_rows($queryTot);
$queryRecords = mysqli_query($conn, $sqlRec) or die("error to fetch employees data");
while( $row = mysqli_fetch_array($queryRecords) ) {
$result1 = $row[0];
$result2 = $row[1];
$result3 = $row[2];
$result4 = $row[3];
$result5 = $row[4];
$result6 = $row[5];
$result7 = $row['date_difference'];
$data[] = array($result1, $result2, $result3, $result4, $result5, $result6, $result7);
}
$json_data = array(
"draw" => intval( $params['draw'] ),
"recordsTotal" => intval( $totalRecords ),
"recordsFiltered" => intval($totalRecords),
"data" => $data // total data array
);
echo json_encode($json_data); // send data as json format]
<?php
>
```
?>
This discussion has been closed.