[eluser]rochellecanale14[/eluser]
Hello today i am integrating CI and Smarty and I got an error in database query. Here's what i did.
Model:
//admin_model.php
<?php
class Admin_Model extends CI_Model{
public function __construct(){
parent::__construct();
}
public function viewAllMember(){
$sql = "SELECT * FROM tbl_admin";
$result = $this->db->query($sql); //the error?
return $result;
}
}
?>
Controller:
//admin_controller.php
<?php
class Admin_Controller extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
$this->smarty->assign('title','Account Setting');
$list = $this->admin_model->viewAllMember(); //error?
foreach($list->result_array() as $row){
$id = $row['id'];
//$username = $row['username'];
}
$this->smarty->assign('id',$id); //Use for testing purposes only
$this->smarty->view('admin/index');
}
}
?>
Smarty template
//index.tpl
<html>
<head>
<title>TEST</title>
</head>
<body>
{$id}
</body>
</html>
Could you tell me where's my error? And how can i display all my tables data? where should i extract it? In controller or view? I am now studying smarty together with codeigniter.