title: how is convert and fix error in this code to CodeIgniter?
body: <p>how is convert this code to CodeIgniter code:</p>
  
  <p>search_hotel: -> this is CI_Model</p>
  
  <pre><code>return mysql_query("select * from hotel_submits where name LIKE '".$searchterm."'")
  </code></pre>
  
  <p>i try but have error:</p>
  
  <pre><code>$query = $this-&gt;db-&gt;order_by("id", "desc")-&gt;like('name', '$searchterm')-&gt;get('hotel_submits');
          return $query-&gt;row();
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>A PHP Error was encountered
  Severity: Warning
  Message: mysql_fetch_assoc() expects parameter 1 to be resource, array given
  Filename: admin/tour.php
  Line Number: 15
  
  
  A PHP Error was encountered
  Severity: Notice
  Message: Undefined variable: data
  Filename: admin/tour.php
  Line Number: 21
  </code></pre>
  
  <p>code:-> this is CI_Controller</p>
  
  <pre><code>$searchterm = $this-&gt;input-&gt;post('search_hotel');
  $result = $this-&gt;model_tour-&gt;search_hotel($searchterm);
  while ($row = mysql_fetch_assoc($result)) { //this is line 15
  //giving names to the fields
  $data = array (
     'name' =&gt; $row-&gt;name,            
  );
  }
  echo json_encode($data);  //this is line 21
  </code></pre>