それっぽくなってきたー!
ただflexigridの方が見栄えはいいかな..
controller 'welcome'
public function page($offset = 0) { $url = 'http://XXXX/welcome/page/'; $pagination = 15; $dbname = 'XXXXX'; if (!$this->tank_auth->is_logged_in()) { redirect('/auth/login/'); } else { $data['user_id'] = $this->tank_auth->get_user_id(); $data['username'] = $this->tank_auth->get_username(); $result = ""; $query = $this->db->get($dbname,$pagination,$offset); $config['base_url'] = $url; $config['total_rows'] = $this->db->count_all($dbname); $config['per_page'] = $pagination; $this->pagination->initialize($config); $res = $query->result(); for($i=0;$i<count($res);$i++) { $item = current($res); if(!next($res)) break; $result .= "<tr>"; $result .= "<td>" . $item->ID . "</td>"; $result .= "<td>" . $item->name . "</td>"; $result .= "<td>" . $item->disease . "</td>"; $result .= "</tr>\n"; } $data['result'] = $result; $data['pagination'] = $this->pagination->create_links(); $this->load->view('welcome', $data); } } function index() { // create a temporary user object $this->page(0); }
view 'welcome'
<table width="100%" border="0"> <tr> <td align="left">ユーザ: <?php echo $username; ?></td> <td align="right"><?php echo anchor('/auth/logout/', 'ログアウト'); ?></td> </tr> </table> <hr> <table width="100%" border="0" cellpadding="2"> <?php echo $result; ?> </table> <?php echo $pagination; ?>