I have this PHP code:
foreach( $wpdb->get_results( ) as $key => $row) { echo \"[\'\". $row->DATE . \"\',\". $row->total_sales . \"],\"; }
php has a trim function, give it a string and the comma.
$s = trim ($s,",")