[eluser]therealmaloy[/eluser]
Solarpitch
Here's a sample code for you to base with, might not be perfect, i haven't totally run this, but i guess the ideas and implementation are all in here... good luck.
let me know if something comes up
Model //assume the model class exists and the function below to be in it
Code:
function sales_breakdown($limit = FALSE, $offset = FALSE)
{
$this->db->limit($limit);
$this->db->offset($offset);
$query = $this->db->get('sales');
return $query;
}
Controller //assume that the class exists and the model was properly loaded
Code:
function sales_breakdown()
{
$this->load->library('pagination');
$config['base_url'] = 'http://mysite.ie/enterprise/index.php/enterprise/sales_breakdown';
$config['total_rows'] = '200';
$config['per_page'] = '20';
$this->pagination->initialize($config);
$query = $this->report_model->sales_breakdown($this->pagination->per_page, $this->uri->segment(x)); //x is the segment position to get the offset for pagination to get the next set of items
if ($query->result())
{
$data['sales'] = $query->result();
$data['pagination'] = $this->pagination->create_links();
$this->load->view('sales_view',$data);
}
}
View //can be saved in the view directory as sales_view.php
Code:
<table border='0' cellspacing='0' cellpadding='0' id='breakdown_table'>
<tr>
<td>Item</td>
<td>Price</td>
<td>Type</td>
<td>Category</td>
<td>Time</td>
</tr>
<?php foreach ($sales as $row) { ?>
<tr >
<td><?=$row->item?></td>
<td>€<?=$row->price?></td>
<td><?=$row->type?></td>
<td><?=$row->temp3?></td>
<td><?=$row->time?></td>
</tr>
<?php } >
</table>
<br/>
<br/>
<?=$pagination?>