2 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
6 /* Array of database columns which should be read and sent back to DataTables. Use a space where
7 * you want to insert a non-database field (for example a counter or static image)
9 $aColumns = array( 'name', 'phone', 'email', 'city', 'zip' );
11 /* Indexed column (used for fast and accurate table cardinality) */
17 /* Database connection information */
19 $gaSql['password'] = "";
21 $gaSql['server'] = "localhost";
23 /* REMOVE THIS LINE (it just includes my SQL connection user/pass) */
24 include( $_SERVER['DOCUMENT_ROOT']."/datatables/mysql.php" );
27 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
28 * If you just want to use the basic configuration for DataTables with PHP server-side, there is
29 * no need to edit below this line
35 $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
36 die( 'Could not open connection to server' );
38 mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
39 die( 'Could not select database '. $gaSql['db'] );
46 if ( isset( $_GET['iStart'] ) && isset( $_GET['iLength'] ) )
48 $sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iStart'] ).", ".
49 mysql_real_escape_string( $_GET['iLength'] );
53 echo '{ "aaData": [] }';
62 SELECT ".str_replace(" , ", " ", implode(", ", $aColumns))."
67 $rResult = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
73 $sOutput .= '"aaData": [ ';
74 while ( $aRow = mysql_fetch_array( $rResult ) )
77 for ( $i=0 ; $i<count($aColumns) ; $i++ )
80 $sOutput .= '"'.str_replace('"', '\"', $aRow[ $aColumns[$i] ]).'",';
84 * Optional Configuration:
85 * If you need to add any extra columns (add/edit/delete etc) to the table, that aren't in the
86 * database - you can do it here
90 $sOutput = substr_replace( $sOutput, "", -1 );
93 $sOutput = substr_replace( $sOutput, "", -1 );