<?php class Database1 extends CI_controller{ function __construct(){ parent:: __construct(); $this->load->database(); } function index(){ $data['records']=$this->db->get('profile')->result_array(); $this->load->view('database_view',$data); } }
<html> <body> <table> <?php foreach ($records as $row): ?> <tr> <td><?=$row['名前']?></td> <td><?=$row['性別']?></td> <td><?=$row['生年月日']?></td> </tr> <?php endforeach; ?> </table> </body> </html>
<?php class Model_get extends CI_Model{ public function __construct(){ parent::__construct(); } }
現在、コントローラにデータベースの処理を記述していますが、
これをモデルの方に修正したいです。最終的にviewで表示するところは同じですが、どう記述すればよいでしょうか。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。