0

I have 2 models: [sales] and [tax].

Now I want a view to show data from [sales] and [tax], and then subtract it so that it becomes like this: grandtotal = [sales] - [tax]

Sales table:

date   : 2019-04-03 
sales  : 200<br/>

Tax table:

date  : 2019-04-03
tax   : 50<br/>

This is my code in view:

<?php if($sales->num_rows() > 0 and $tax->num_rows() > 0  ) { ?>

<?php $no = 1; $total_sales = 0; $total_tax = 0;
    foreach($sales->result() as $p ) {
        foreach($tax->result() as $b )
        { 
            echo date('d F Y', strtotime($p->date and $b ->date))
            Rp. .str_replace(",", ".", number_format($p->total_sales))
            Rp. .str_replace(",", ".", number_format($b->total_tax))

            $total_sales = $total_sales + $p->total_sales;
            $no++;

            $total_tax = $total_tax + $b->total_tax;
            $no++;


            Rp. ".str_replace(",", ".", number_format($total_sales - $total_tax))."
       }
    }
 ?>

Error massage:

Data from 01 January 1970 to 01 January 1970 not found

jkdev
  • 9,037
  • 14
  • 52
  • 75

0 Answers0