CodeIgniter: Choosing a Data From GET

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:

	class Books_model extends Model{
	function Books_model(){



	function books_get($id){


	$query =$this->db->getwhere('books',array('id'=>$id));
	return $query->row_array();


codeigniter model

For Controller: Open “books.php” within CodeIgniter\system\application\controllers. Add following function:

class Books extends Controller{
	function Books(){



	function Get($id){




codeigniter result

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.
codeigniter result putput


the coder

One Comment on "CodeIgniter: Choosing a Data From GET"

  1. Tanim says:

    This was very helpful…… Thanx a lot

Got something to say? Go for it!


More in beginners (1 of 10 articles)