title: Return a single variable value (string) from the model and fill it in the text field of view - Codeigniter
body: <p>I have the following Model, Controller and view. Using PHP Point of Sale 11.3. 
  I'm trying to take the max value in a DB column and display it in a text field in view.</p>
  
  <p>Model:</p>
  
  <pre><code>function getmax()
  {
      $query = $this-&gt;db-&gt;query("SELECT max(item_id) FROM phppos_items");
      return $query-&gt;row();
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>function view()
  {   
      $data['max_id']=$this-&gt;Item-&gt;getmax();      
      $this-&gt;load-&gt;view("items/form",$data);
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;?php 
  
      echo $max_id; //line 16. Error Here.
  
      echo form_input(array(
                          'name'=&gt;'item_number',
                          'id'=&gt;'item_number',
                          'value'=&gt;set_value('item_number',$max_id)) //is this right??
                      );
  ?&gt;
  </code></pre>
  
  <p>Am getting two errors when execution.</p>
  
  <pre><code>A PHP Error was encountered
  Severity: 4096
  Message: Object of class stdClass could not be converted to string
  Filename: items/form.php
  Line Number: 16
  
  A PHP Error was encountered
  Severity: Warning
  Message: htmlspecialchars() expects parameter 1 to be string, object given
  Filename: helpers/form_helper.php
  Line Number: 625
  </code></pre>
  
  <p>I'm getting the max_id without any issues when used as dropdown in view.</p>
  
  <pre><code>&lt;?php echo form_dropdown('max_id',$max_id);?&gt;
  </code></pre>
  
  <p>But I need this value to be filled in default in the form text field. 
  Thanks in advance.</p>