Trying to add two table [html table, not database table] in one view - El Forum - 06-04-2012
[eluser]Azraf[/eluser]
I am using HTML Table Class to create tables. I need to generate 4 table in one view page.
My controller:
Code: public function license_detail($id='')
{
$id = $this->uri->segment(3);
$this->load->model('Admin_model', '', TRUE); // This line is actually in __construct() method;
$data = array();
if( is_numeric($id) && ($id > 0)){
$this->load->library('table');
$infoAr = $this->Admin_model->getLicDetail($id);
$data['licNum'] = $infoAr->lic_number;
$data['infoRelPlAr'] = $this->Admin_model->getRelLicPlDetail($id);
$data['infoRelCbhAr'] = $this->Admin_model->getRelLicCbhDetail($id);
$data['infoRelWchAr'] = $this->Admin_model->getRelLicWchDetail($id);
$this->table->add_row('<strong>License Number</strong>', $infoAr->lic_number);
$this->table->add_row('<strong>Entity</strong>', $infoAr->entity);
$this->table->add_row('<strong>Issue Date</strong>', $infoAr->issue);
$this->table->add_row('<strong>Expire Date</strong>', $infoAr->expire);
...................
$this->load->view('admin/license-detail', $data);
} else {
redirect('wrong_place');
}
}
In my View:::
Code: <div class="clear-h"></div>
[b]<?php echo $this->table->generate(); ?>[/b]
<div class="clear-h"></div>
[b]<?php echo $this->table->generate($infoRelPlAr); ?>[/b]
<div class="clear-h"></div>
[b]<?php echo $this->table->generate($infoRelCbhAr); ?>[/b]
<div class="clear-h"></div>
[b]<?php echo $this->table->generate($infoRelWchAr); ?>[/b]
Hrer in the view, I want to customaize each table. Can you help me to give a hints how to style/customize each table?
My Model (if you want to give a look...):
Code: public function getLicDetail($id = '')
{
if(empty($id)){return false;}
$this->db->select('
lic_info.id, lic_info.lic_number, lic_info.entity, lic_info.issue, lic_info.expire, lic_info.ls_status, lic_info.ls_desc, lic_info.join-date, lic_info.last_modified,
..........
');
$this->db->from('lic_info');
$this->db->where('lic_info.id', $id);
$this->db->join('bi_info', 'lic_info.id = bi_info.data_id', 'inner');
.........
$this->db->order_by("lic_info.id", "asc");
$this->db->limit(1);
$query = $this->db->get();
return $query->row();
}
public function getRelLicPlDetail($id = '')
{
if(empty($id)){return false;}
$this->db->select('
pl_fname, pl_mname, pl_lname, pl_title, pl_as_date, pl_disas_date, pl_class, pl_more_class
');
$this->db->from('pl_info');
$this->db->where('data_id', $id);
$this->db->order_by("id", "asc");
$query = $this->db->get();
return $query->result_array();
}
public function getRelLicCbhDetail($id = '')
{
if(empty($id)){return false;}
$this->db->select('
id, cbh_surety, cbh_bond, cbh_bond_amount, cbh_eff_date, cbh_cancel_date
');
$this->db->from('con_bond_his');
.......
$query = $this->db->get();
return $query->result_array();
}
.......
Trying to add two table [html table, not database table] in one view - El Forum - 06-04-2012
[eluser]Azraf[/eluser]
Sorry for mis styling, Here view is actually:
[code]
<div class="clear-h"></div>
<?php echo $this->table->generate(); ?>
<div class="clear-h"></div>
<?php echo $this->table->generate($infoRelPlAr); ?>
<div class="clear-h"></div>
<?php echo $this->table->generate($infoRelCbhAr); ?>]
<div class="clear-h"></div>
<?php echo $this->table->generate($infoRelWchAr); ?>
.......
Any comment/solution will highly appreciated.
Trying to add two table [html table, not database table] in one view - El Forum - 06-04-2012
[eluser]Learn CodeIgniter[/eluser]
You need to do this before setting up the other tables and after each table.
Code: $this->table->clear();
View
Code: <div class="clear-h"></div>
[b]<?php echo $this->table->generate(); ?>[/b]
<div class="clear-h"></div>
<?php $this->table->clear(); ?>
[b]<?php echo $this->table->generate($infoRelPlAr); ?>[/b]
<div class="clear-h"></div>
<?php $this->table->clear(); ?>
[b]<?php echo $this->table->generate($infoRelCbhAr); ?>[/b]
<div class="clear-h"></div>
<?php $this->table->clear(); ?>
[b]<?php echo $this->table->generate($infoRelWchAr); ?>[/b]
</div>
Trying to add two table [html table, not database table] in one view - El Forum - 06-04-2012
[eluser]Azraf[/eluser]
Thank. Now everything is working fine.
I have set in my Controller
Code: $data['infoRelPlAr'] = $this->Admin_model->getRelLicPlDetail($id);
$data['infoRelPlArHd'] = array('First Name', 'Middle Name', 'Last Name', 'Title', 'Association Date', 'Disassociation Date', 'Class', 'More Class');
and in my View:
Code: <?php echo $this->table->generate(); ?>
<div class="clear-h"></div>
<?php
$this->table->clear();
$this->table->set_heading($infoRelPlArHd);
echo $this->table->generate($infoRelPlAr);
?>
Now Heading is also coming for each table.
It helps me a lot. Thanks again.
|