In this example, we will show how to fetch data in textarea in codeigniter. We will how to fetch data from the database in textarea using Codeigniter. You can learn to fetch data in textarea with codeigniter.

We will provide a simple example of how to fetch data from textarea in Codeigniter. After read this post you can simply fetch data in your textarea using Codeigniter.


Create Controller

defined('BASEPATH') OR exit('No direct script access allowed');

class DemoController extends CI_Controller {
    function __construct() {
    function demo(){
        $data['demo'] = $this->demo->get_row_by_id('demo', array("id"=>1));

Create Model

create Demo model 


class Demo extends CI_Model
    function __construct()

    function get_row_by_id($table_name,$where_array){
        $query = $this->db->get();
        if ($query->num_rows() > 0){
            return $query->row();
            return false;

Create View

create demo view

<!DOCTYPE html>
<html lang="en">
  <title>How to Fetch Data in Textarea in CodeIgniter</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="">
  <script src=""></script>
  <script src=""></script>

<div class="container">
  <h2>How to Fetch Data in Textarea in CodeIgniter</h2>

  <form method="post">

    <div class="form-group">
      <label for="message">Message:</label>
      <input type="hidden" name="id" value="<?= $demo->id ?>">
      <textarea class="form-control" id="message" placeholder="Enter message" name="message"><?= $demo->message ?></textarea>
    <button type="submit" class="btn btn-primary">Update</button>


Thanks may this example help you.....