title: Calculating a total value and then adding VAT in a Controller Code Igniter
body: <p>I have some Data coming out of my DB Model. What I want to do is get the total amount of the PAYMENTS_total and then times it by VAT (0.20) </p>
  
  <p>I'm assuming I need to creat some sort of FOR loop somewhere, But not too sure where?</p>
  
  <p>My Code for the controller is :</p>
  
  <pre><code>function vat_list()
      {
          if(isset($_POST['search_date']))
          {
              $search_date = $this-&gt;input-&gt;post('search_date', TRUE);
          }
          else
          {
              $search_date = date('D j M Y', strtotime('today - 7 days')) . ' to ' . date('D j M Y');
          }
  
          $my_result_data = $this-&gt;Invoices_model-&gt;read_vat($this-&gt;viewinguser-&gt;BUSINESSES_id, $search_date);
          $my_results = $my_result_data-&gt;result();
  
          $vat_total = $my_results[0]-&gt;PAYMENTS_total;
          $vat_total = number_format($my_results[0]-&gt;PAYMENTS_total, 2, '.', '') * 0.20;
  
          $this-&gt;template-&gt;set('title', 'View VAT Reports');
          $this-&gt;template-&gt;set('subtitle', $search_date);
          $this-&gt;template-&gt;set('vat_items', $my_results);
          $this-&gt;template-&gt;set('vat_total', $vat_total);
          $this-&gt;template-&gt;build('accounts/invoices/vat_list');
      }
  </code></pre>
  
  <p>Thanks</p>