Lo que me pasa es que todo me pincha bien el filtro por campo pero no asi el ordenar por columna y al cambiar de pagina me sigue mostrando los mismos registros de ante mano gracias
mi codigo php tomado del foro de http://www.datatables.net y modificado a mis necesidades
Código:
<?php /* MSSQL connection */ //require('connect.php'); //i used am include for my connection /* Database connection information */ $gaSql['user'] = "usuario"; $gaSql['password'] = "Password"; $gaSql['db'] = "basedato"; $gaSql['server'] = "server"; /* MSSQL connection*/ $gaSql['link'] = mssql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or die( 'Could not open connection to server' ); mssql_select_db( $gaSql['db'], $gaSql['link'] ) or die( 'Could not select database '. $gaSql['db'] ); //Count of all records $cQuery = "SELECT COUNT(*) as total_count FROM ajax"; $rResultTotal = mssql_query($cQuery); $aResultTotal = mssql_fetch_array($rResultTotal); $iTotal = $aResultTotal[0]; //print_r ($aResultTotal); /****** Paging ********/ $sLimit = ""; if ( isset( $_GET['iDisplayStart'] ) ) { $sLimit = "TOP ".( $_GET['iDisplayLength'] ); } /******* Ordering *********/ $sOrder = ""; if ( isset( $_GET['iSortCol_0'] ) ) { $sOrder = "ORDER BY "; for ( $i=0 ; $i<( $_GET['iSortingCols'] ) ; $i++ ) { $sOrder .= fnColumnToField(( $_GET['iSortCol_'.$i] ))." ".( $_GET['sSortDir_'.$i] ) .", "; } $sOrder = substr_replace( $sOrder, "", -2 ); } /* Filtering - NOTE this does not match the built-in DataTables filtering which does it * word by word on any field. It's possible to do here, but concerned about efficiency * on very large tables, and MySQL's regex functionality is very limited SELECT FIELD NAMES From table_name */ $sWhere = ""; if ( $_GET['sSearch'] != "" ) { $sWhere = "WHERE engine LIKE '%".$_GET['sSearch']."%' OR "."browser LIKE '%".$_GET['sSearch']."%' OR "."platform LIKE '%".$_GET['sSearch']."%' OR "."version LIKE '%".$_GET['sSearch']."%' OR "."grade LIKE '%".$_GET['sSearch']."%'"; } $fil_Query = "SELECT COUNT(*) as filert_info From ajax $sWhere "; $fil_Result = mssql_query($fil_Query); $afil_Result = mssql_fetch_array($fil_Result); $iFilteredTotal = $afil_Result[0]; /////////////////////////////////////////////////////////////////////////////// // AQUI ESTAN Los campos a mostrar en el grid // // $sQuery = "SELECT ".$sLimit." FIELD NAMES // /////////////////////////////////////////////////////////////////////////////// $sQuery = "SELECT ".$sLimit." engine,browser,platform,version,grade From ajax $sWhere "; $rResult = mssql_query($sQuery) ; $sOutput = '{'; $sOutput .= '"sEcho": '.intval($_GET['sEcho']).', '; $sOutput .= '"iTotalRecords": '.$iTotal.', '; $sOutput .= '"iTotalDisplayRecords": '.$iFilteredTotal.', '; $sOutput .= '"aaData": [ '; while ( $aRow = mssql_fetch_array( $rResult ) ) { $sOutput .= "["; $sOutput .= '"'.$aRow[0].'",'; $sOutput .= '"'.$aRow[1].'",'; $sOutput .= '"'.$aRow[2].'",'; $sOutput .= '"'.$aRow[3].'",'; $sOutput .= '"'.$aRow[4].'"'; $sOutput .= "],"; } $sOutput = substr_replace( $sOutput, "", -1 ); $sOutput .= '] }'; echo $sOutput; function fnColumnToField( $i ) { if ( $i == 0 ) return "engine"; else if ( $i == 1 ) return "browser"; else if ( $i == 2 ) return "platform"; else if ( $i == 3 ) return "version"; else if ( $i == 4 ) return "grade"; } ?>