Welcome Guest, Not a member yet? Register   Sign In
Summing Data in a Table
#1

[eluser]Einspruch[/eluser]
I am a noob so forgive me if this question is way too simple or way too complex. But here goes:

I have a function in a model that pulls royalty by partner by month. I use the following code in the controller to call the function:

Code:
function royalty_by_partner()
    {
        $this->load->model('partner_model');
        $data['query'] = $this->partner_model->royalty_by_partner();
        $this->load->view('partner/royalty_by_partner', $data);
    }

The data--royalty by partner--is then rendered in a table. All is well. Until I was asked to add a row at the bottom of the table summarizing the data (i.e., total royalty revenue for the month).

My first thought was to create a separate function in the same model that sum royalty revenue by month and have the same controller function pass it to the view. Then I would render it in a separate table, but to the user it would look like a single table with a summary line.

So my question is the following: how do I pass both sets of data (two functions within the same model) to a single view? Is it possible given the structure of my controller/function?
#2

[eluser]Thorpe Obazee[/eluser]
Code:
$data['that'] = $this->urmodel->get_that();
$data['this'] = $this->urmodel->get_this();

$this->load->view('the/view', $data);

It's possible. The simplest way is -----^
#3

[eluser]Einspruch[/eluser]
Thanks a million. It worked perfectly!




Theme © iAndrew 2016 - Forum software by © MyBB