Welcome Guest, Not a member yet? Register   Sign In
Trying to add two table [html table, not database table] in one view
#1

[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]&lt;?php  echo $this->table->generate(); ?&gt;[/b]
                
                <div class="clear-h"></div>
                [b]&lt;?php echo $this->table->generate($infoRelPlAr); ?&gt;[/b]
                
                <div class="clear-h"></div>
                [b]&lt;?php echo $this->table->generate($infoRelCbhAr); ?&gt;[/b]
                
                <div class="clear-h"></div>
                [b]&lt;?php echo $this->table->generate($infoRelWchAr); ?&gt;[/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();
    }
.......
#2

[eluser]Azraf[/eluser]
Sorry for mis styling, Here view is actually:
[code]
<div class="clear-h"></div>
&lt;?php echo $this->table->generate(); ?&gt;

<div class="clear-h"></div>
&lt;?php echo $this->table->generate($infoRelPlAr); ?&gt;

<div class="clear-h"></div>
&lt;?php echo $this->table->generate($infoRelCbhAr); ?&gt;]

<div class="clear-h"></div>
&lt;?php echo $this->table->generate($infoRelWchAr); ?&gt;
.......
Any comment/solution will highly appreciated.
#3

[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]&lt;?php  echo $this->table->generate(); ?&gt;[/b]
                
                <div class="clear-h"></div>
                &lt;?php $this->table->clear(); ?&gt;
                [b]&lt;?php echo $this->table->generate($infoRelPlAr); ?&gt;[/b]
                
                <div class="clear-h"></div>
                &lt;?php $this->table->clear(); ?&gt;
                [b]&lt;?php echo $this->table->generate($infoRelCbhAr); ?&gt;[/b]
                
                <div class="clear-h"></div>
                &lt;?php $this->table->clear(); ?&gt;
                [b]&lt;?php echo $this->table->generate($infoRelWchAr); ?&gt;[/b]
</div>
#4

[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:
&lt;?php echo $this->table->generate(); ?&gt;
<div class="clear-h"></div>
&lt;?php
$this->table->clear();
$this->table->set_heading($infoRelPlArHd);
echo $this->table->generate($infoRelPlAr);
?&gt;
Now Heading is also coming for each table.

It helps me a lot. Thanks again.




Theme © iAndrew 2016 - Forum software by © MyBB