title: how retrieve sum of multiple column ? codeigniter
body: <p>i have a table sales_items ,where we save all sales item with all details -my table is : </p>
  
  <hr>
  
  <pre><code>sales_id  | sales item| No.ofpacks |   quantity(liters pr pack) | 
  ---------     ----------- ------------   ---------------- 
     31           petrol        2               2.5
     31           disel de2     3               3.2
     34           petrol se     2               4.2
     31           castrol       7               4.1
  ------------------------------------------------------------------
  </code></pre>
  
  <p>now we want total number of liters at any one sales_id , means if we take sales_id 31 , then we want total <code>liters =(2*2.5) + (3*3.2) +(7*7.2),</code>  i search but not found any suitable help on google .
  we try :</p>
  
  <pre><code>public function total_liter($id) {
          $q = $this-&gt;db-&gt;get_where('sale_items', array('sale_id' =&gt; $id), 1);
          if ($q-&gt;num_rows() &gt; 0) {
              foreach($q as $row):
  
              $total_liter += $row['no_of_packs']*$row['quantity'];
              endforeach;
          }
          return FALSE;
      } 
  </code></pre>