How to keep variable value use throughout all records in clistview

36 views Asked by At

i have used clistview.

my requirement is to print total on each record.

like following in randerPartial _view.php,

1'st record

total= total+$data->amount(value 100);
total=100;

2'nd record

total= total+$data->amount(value 100);
total=200;

3'rd record

total= total+$data->amount(value 100);
total=300;

and so on....

but i cant get last updated value of total variable.
it overwrite value in each record. how to keep variable updated and used.

1

There are 1 answers

0
Let me see On BEST ANSWER

Better solution will be to create a variable in your controller like

class AbcController extends Controller
{
    public $total=0;
}

and then use it in your renderPartial _view.php like

$this->total += $data->amount(value 100);