title: CodeIgniter: Array to string conversion error on a page supposed to retrieve data from a table, then edit and update
body: <p><strong>I'm trying to get records and let users of the application edit details of records and update new details. But when I print_r ($row->emp_name) it returns: John Smith and ($row->emp_type) returns Cachier which are correct values. But why those data are not passed into the 'emp_name' and 'emp_type' inputs in the view?</strong> </p>
  
  <p>Second question:
  I also want to know how to define a value for a dropdown, to be selected on load. Note that the dropdown values has to be from a database and should be retrieved in a similar way described above.</p>
  
  <p><img src="https://i.stack.imgur.com/ceU5S.png" alt="enter image description here"></p>
  
  <hr>
  
  <p><strong>View:</strong></p>
  
  <pre><code>&lt;?php
      $js = 'id="emp_name"';
      echo form_input('emp_name', $emp_name, set_value('emp_name'), $js);
  ?&gt;
  </code></pre>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>function index() {
      $this-&gt;load-&gt;model('edit/default_price_model');
  
      //$data['query'] = $this-&gt;default_price_model-&gt;get_employees_table();
      $this_employee['emp_name'] = $this-&gt;default_price_model-&gt;current_cmployees();
      //$temp_array=array_merge($data, $this_employee);
  
      $this-&gt;load-&gt;view('/edit/employees', $this_employee);
  }
  
  function form_validation() {
  
      if($this-&gt;input-&gt;post('this_employee') == "View") {         
          $this-&gt;populate_form();
      }
      else {
          $this-&gt;load-&gt;library('form_validation');
  
          $this-&gt;form_validation-&gt;set_rules('emp_name','Employee Name', 'required|min_length[3]|max_length[60]');
          $this-&gt;form_validation-&gt;set_rules('emp_type','Employee Name', 'required');
          $this-&gt;form_validation-&gt;set_rules('emp_description','Optional Description', 'max_length[500]');
  
          if ($this-&gt;form_validation-&gt;run() == FALSE ) {
              $this-&gt;index();
          }       
          else {
              $this-&gt;update_table();
          }
      }
  }
  
  function populate_form() {
      $this-&gt;load-&gt;model('edit/default_price_model');
      $selection = $this-&gt;input-&gt;post('select_employee');
      $data['emp_name'] = $this-&gt;default_price_model-&gt;get_employees_table($selection);
      $this-&gt;index();
  }
  </code></pre>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>function get_employees_table($selection) {
      $query = $this-&gt;db-&gt;query(" SELECT emp_name, emp_type, emp_description
                                  FROM employees 
                                  WHERE emp_name='$selection' 
                                  ORDER BY emp_name ASC 
                                  LIMIT 1");
      if($query-&gt;num_rows()&gt;0) {
          foreach($query-&gt;result() as $row) {
              $row-&gt;emp_name;
              $row-&gt;emp_type;
              $row-&gt;emp_description;
          }
      }
  }
  </code></pre>