title: How to retrieve data and display in the textarea of view after Search the data in Codeigniter
body: <p>I am new to Codeigniter. 
  I would like to create a module that after search the id, than it will retrieve data from the database and display the data in the textarea. 
  I have no idea that how to retrieve data from database, and display the data in the textarea after click the 'Search' button.
  Hope someone can help me. Thank You.</p>
  
  <p>This is the Model:</p>
  
  <pre><code>function search($code){
     $this-&gt;db-&gt;select('name','telno','address','introducer');
     $this-&gt;db-&gt;from('customer');
     $this-&gt;db-&gt;like('code',$code);
     $query = $this-&gt;db-&gt;get();
     if($query-&gt;num_rows() &gt; 0){
      return $query-&gt;result();
     }else{
      return $query-&gt;result();
     }
  }
  </code></pre>
  
  <p>This is the Controller:</p>
  
  <pre><code>public function searchcus(){ 
      $this-&gt;load-&gt;model('Ordering_model');
      $pgcode = $this-&gt;input-&gt;post('search');
      if(isset($code) &amp;&amp; !empty($code)){
          $data['customer'] = $this-&gt;Ordering_model-&gt;search($code);
          $this-&gt;load-&gt;view('ordering/index',$data);
      }else{
          redirect($this-&gt;index());
      }
  }
  </code></pre>
  
  <p>This is the View:</p>
  
  <pre><code>&lt;div class="container"&gt;
              &lt;div class="col-md-6"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;div class="col-md-9"&gt;
                              &lt;input type="text" class="form-control" name="search" id="search" placeholder="&lt;?php echo "Customer's PG Code";?&gt; " required /&gt;
                      &lt;/div&gt;
                      &lt;span class="input-group-btn"&gt;
                          &lt;button class="btn btn-default" type="submit" name="submit" value="Search" &gt;&lt;span class="glyphicon glyphicon-search"&gt;&lt;?php echo "Search"; ?&gt;&lt;/span&gt;&lt;/button&gt;
                      &lt;/span&gt;
                      &lt;/div&gt;
              &lt;/div&gt;
              &lt;/form&gt;&lt;br/&gt;
      &lt;/div&gt;
      &lt;table style="width: 2000px;" class="table table-striped"&gt;
                   &lt;div class="col-xs-4"&gt;
                      &lt;div class="input-group"&gt;
                      &lt;span class="input-group-addon"&gt;Name&lt;/span&gt;
                      &lt;input id="msg" type="text" class="form-control" name="msg" &gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;br&gt;&lt;br&gt;
                  &lt;div class="col-xs-4"&gt;
                  &lt;div class="input-group"&gt;
                      &lt;span class="input-group-addon"&gt;Tel&lt;/span&gt;
                      &lt;input id="msg" type="text" class="form-control" name="msg" &gt;
                  &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;br&gt;&lt;br&gt;
                  &lt;div class="col-xs-4"&gt;
                  &lt;div class="input-group"&gt;
                      &lt;span class="input-group-addon"&gt;Introducer&lt;/span&gt;
                      &lt;input id="msg" type="text" class="form-control" name="msg" &gt;
                  &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;br&gt;&lt;br&gt;
                  &lt;div class="col-xs-4"&gt;
                  &lt;div class="input-group"&gt;
                      &lt;span class="input-group-addon"&gt;Address&lt;/span&gt;
                      &lt;textarea class="form-control" rows="5" id="address"&gt;&lt;/textarea&gt;
                  &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;br&gt;
  
  
      &lt;/table&gt;
  </code></pre>