set_charset ( "utf8" ); $con->query("SET NAMES 'utf8' COLLATE 'utf8_polish_ci'"); // initilize all variable $params = $columns = $totalRecords = $data = $dataNew = array(); $params = $_REQUEST; //define index of column $columns = array( 0 =>'word', 0 =>'id', 0 =>'id' ); $where = $sqlTot = $sqlRec = ""; if( !empty($params['search']['value']) ) { $where .=" AND ( not_allowet_words.word LIKE '".$params['search']['value']."%' "; } $sql="SELECT word FROM not_allowet_words"; $sqlRec .= $sql; $sqlTot .= $sql; if(isset($where) && $where != '') { $sqlTot .= $where; $sqlRec .= $where; } $sqlRec .= " GROUP BY not_allowet_words.id LIMIT ".$params['start']." ,".$params['length']." "; $queryTot = mysqli_query($con, $sqlTot) or die("database error:". mysqli_error($con)); while( $row = mysqli_fetch_row($queryTot) ) { $totalRecords = $row[0]; } $queryRecords = mysqli_query($con, $sqlTot); //iterate on results row and create new index array of data while( $row = mysqli_fetch_row($queryRecords) ) { $data[] = $row; } while( $row = mysqli_fetch_row($sqlNew) ) { $dataNew[] = $row; } $i=0; foreach($data as $d){ $data[$i][1] = '111'; $data[$i][2] = '222'; $i++; } $json_data = array( "draw" => intval( $params['draw'] ), "recordsTotal" => $totalRecords , "recordsFiltered" => $totalRecords, "data" => $data // total data array ); $json = json_encode($json_data); echo $json; // send data as json format ?>