データベースに保存したお問い合わせを表示する

「HTMLテーブルクラス」を使って、作表します。
詳しくは、マニュアルを見てください。

Filename: controllers/sendmail.php

        public function viewmail() {
                $this->load->database();
                $sql = 'SELECT tName,tSubject,tMail,tDate FROM mail';
                $query = $this->db->query($sql);
                $this->load->library('table');
                $this->table->set_heading('名前', '題名', 'メール','日付');
                $tmpl = array (
                  'table_open' => '<table border="1" cellpadding="4" cellspacing="0">',
                );
                $this->table->set_template($tmpl);
                $data['table'] = $this->table->generate($query);
                $this->load->view('viewmail',$data);
        }

Filename: views/viewmail.php

<?php $this->load->view('elements/header');?>
<h1>お問い合わせメール</h1>
<?php echo $table;?>
<?php $this->load->view('elements/footer');?>