<?php $USER_ID1 = $this->session->userdata('ID'); $totalamount = $this->db->query('select sum(AMOUNT) as AMOUNT from sis_wallet where USER_ID="'.$USER_ID1.'" ')->result_array(); echo $totalamount[0]['AMOUNT']; ?>