Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all articles
Browse latest Browse all 1817

How to change the output before it gets to the table displayed

$
0
0
I am using this method Link: http://www.datatables.net/release-datatables/examples/server_side/server_side.html
to grab my data from a mysql DB/table using php and bootstrap.

All works flawlessly.

My question is how do I change the value drawn from the DB before it is displayed in my html table page:

The Second column [1] is the column that is an enum field with a 'q' or an 'c', I want to change it to a word that corresponds to the letter. 'q' to "Quiz" and 'c' to "Camp".

I am pretty sure it is can be done in here:

/*
 * Output
 */
$output = array(
  "sEcho" => intval($_GET['sEcho']),
  "iTotalRecords" => $iTotal,
  "iTotalDisplayRecords" => $iFilteredTotal,
  "aaData" => array()
);

while ( $aRow = mysql_fetch_array( $rResult ) )
{
  $row = array();
  for ( $i=0 ; $i<count($aColumns) ; $i++ )
  {
    if ( $aColumns[$i] == "version" )
    {
      /* Special output formatting for 'version' column */
      $row[] = ($aRow[ $aColumns[$i] ]=="0") ? '-' : $aRow[ $aColumns[$i] ];
    }
    else if ( $aColumns[$i] != ' ' )
    {
      /* General output */
      $row[] = $aRow[ $aColumns[$i] ];
    }
  }
  $output['aaData'][] = $row;
}

echo json_encode( $output );

Any assistance would be appreciated.

Viewing all articles
Browse latest Browse all 1817

Trending Articles