CodeIgniter Step By Step Tutorial: At previous tutorial, we learn show a data. But we have define ID that we want to show. In this post, we learn how to show a data that ID defined from GET.
For model: Open “books_model.php” within CodeIgniter\system\application\models. Add following function:
<?php
class Books_model extends Model{
function Books_model(){
parent::Model();
}
function books_get($id){
$this->load->database();
$query =$this->db->getwhere('books',array('id'=>$id));
return $query->row_array();
}
}
?>
For Controller: Open “books.php” within CodeIgniter\system\application\controllers. Add following function:
<?php
class Books extends Controller{
function Books(){
parent::Controller();
}
function Get($id){
$this->load->model('books_model');
$data['query']=
$this->books_model->books_get($id);
$this->load->view('books_view',$data);
}
}
?>
Here is the view code within CodeIgniter\system\application\views.
<b>Book Title :</b><?= $query['title'] ?><br/> <b>Author Name :</b><?= $query['author_name'] ?> your code here
Now, test it. Point your browser to http://localhost/CodeIgniter/index.php/Book/Get/1.





This was very helpful…… Thanx a lot