Select (Sum) totals

Select (Sum) totals

dblackwdblackw Posts: 1Questions: 0Answers: 0
edited July 2016 in Free community support

Is there example code of using datatables to do sum totals or other SQL selects in php, I realise the example php code is only a sample - but I'm not sure how to go about adding to it eg SELECT name, SUM(daily_typing_pages)
-> FROM employee_tbl GROUP BY name;

Replies

  • allanallan Posts: 61,864Questions: 1Answers: 10,136 Site admin

    Where it creates the JSON you can add the extra data in there. For example:

    $data = SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns );
    $data['count'] = $myCount;
    echo json_encode( $data );
    

    Then use ajax.json() to access the JSON object on the client-side. You might use:

    footerCallback: function () {
      var json = this.api().ajax.json();
      var count = json.count;
      ...
    }
    

    Allan

This discussion has been closed.