title: Getting a single value from database - Codeigniter
body: <p>I'm trying to get first name and last name of registered users.
  This is my getfirstname , getlastname function in the model</p>
  
  <pre><code>public function getf()
  {  
  
    $email = $this-&gt;input-&gt;post('email');
    $this-&gt;db-&gt;where('email', $this-&gt;input-&gt;post('email'));
    $query = $this-&gt;db-&gt;get('users');
          if($query-&gt;num_rows == 1)
          {
            $row = $query-&gt;row();
            echo $row-&gt;fname;
          }
  
  }
  
  
  public function getl()
  {
      $this-&gt;db-&gt;where('email', $this-&gt;input-&gt;post('email'));
      $query = $this-&gt;db-&gt;get('users');
      if($query-&gt;num_rows == 1)
      {
          $row = $query-&gt;row();
          echo $row-&gt;lname;
      }
  
  }
  </code></pre>
  
  <p>In My Contoller:</p>
  
  <pre><code>public function members()
  {
      if($this-&gt;session-&gt;userdata('is_logged_in'))
      {
  
          $data['fname'] = $this-&gt;getf(); 
          $data['lname'] = $this-&gt;getl();
          $this-&gt;load-&gt;view('members', $data);
      }
      else
      {
          redirect('main/restricted');
      }
  }
  </code></pre>
  
  <p>Im echoing the fname and lname variables in my view which prints 'Array' and not actual firstname and lastname</p>
  
  <pre><code>echo $fname;
  echo $lname;
  </code></pre>