-
Notifications
You must be signed in to change notification settings - Fork 0
db to table
I feel we don't have enough sample code so here is one from me on how to get stuff from the database and feed it in to a table:
[code]
function index()
{
$query = $this->db->getwhere('Ticket', array('uid' => $this->uid));
if ($query->num_rows() > 0)
{
foreach($query->result_array() as $k => $s):
$tbresult[$k] = $s;
endforeach;
// Remove id fields
$tbresult = $this->fun->unsetids($tbresult);
$this->load->library('table');
$this->table->set_heading(array_keys($tbresult[0]));
foreach($tbresult as $row):
$v = $row['Ticket No'];
$row['Ticket No'] = anchor('ticket/view/'.$v,$v);
$this->table->add_row($row);
endforeach;
$this->tpl['body'] = $this->table->generate();
$this->table->clear();
}
Image:Screenshot.gif $this->load->view('layout/blank', $this->tpl); } [/code]