mysql - link table in codeigniter -



mysql - link table in codeigniter -

i'm newbie using codeigniter ,i'm larn develop application base of operations on mysql database school project, have 10table ( table1,table2,....table10), i'm create model

class show_model extends ci_model{ function __construct() { parent ::__construct(); } function table1() { $query1 = $this->db->get('table1'); homecoming $query1->result(); } function table2() { $query2 = $this->db->get('table2'); homecoming $query2->result(); } bla....bla...................... function table10() { $query10 = $this->db->get('table10'); homecoming $query10->result(); } }

and controller

class show extends ci_controller{ function __construct(){ $this->load->model('show_model'); } function show_table1() { $data['show_table1'] = $this->show_model->table1(); $this->load->view('v_page_1',$data); } function show_table2() { $data['show_table2'] = $this->show_model->table2(); $this->load->view('v_page_2',$data); } bla....bla.... }

and goal :

how code

how show / view on 1 page , create link each table show

this want show:

clik show : table1|tabel2|table3|......| ----------------------- |itema | itemb |itemc | ----------------------- | | | | | | | | -----------------------

cant help me, or explained how can that, or maybe share link tutorial

you can pass table want show in controller parameter. create function create menu. don't need model if utilize $this->db->get('');.

class show extends ci_controller { private $tables = array('table1', 'table2', 'table3' ....); public function show_table($table) { if (! in_array($table, $this->tables)) { show_404(); } $data['table'] = $this->db->get($table)->result(); $menu = $this->get_menu(); $this->load->view('show_table', array( 'table' => $this->load->view('v_table_'. $table, $data, true), 'menu' => $menu, } private function get_menu() { $menu = ''; foreach ($this->tables $table) { $menu .= '<a href="'. base_url('show/show_table/'. $table) .'">'. $table .'</a>'; } } }

mysql codeigniter

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -