Hello everyone,

I have 2 tables:
- contacts: contactID, firstName, lastName,..., cityID
- city: cityID, cityName

I've built my controller, model and view but it's only fetching 3 records from the table while I have 5.

This is my controller
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
App extends CI_Controller {

    function 
__construct()
    {
        
parent::__construct();
        
        
/* Standard Libraries */
        
$this->load->database();
        
/* ------------------ */
        
$this->load->model('app_model');
        
$this->load->helper('url'); //Just for the examples, this is not required thought for the library
        
        
    
}
    
    function 
index()
    {
        
//$this->db->select('*');
        //$this->db->from('contacts');
        //$this->db->join('city', 'city.cityID = contacts.cityID');
        
$data['query'] = $this->app_model->get_all_posts();
        
$this->load->view('app_view'$data);
        
    }
    function 
_example_output($output null)
 
    {
        
$this->load->view('app_view.php',$output);    
    }
    
}
My Model
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
App_model extends CI_Model {
    
    function 
__construct() {
        
parent::__construct();
        
$this->load->database();    
    }
    
    function 
get_all_posts() {
        
$query $this->db->query('SELECT * FROM contacts JOIN city ON city.cityID = contacts.contactID');
        return 
$query->result();    
    }
}
and my view
PHP Code:
<?php if($query) { 
                foreach (
$query as $contact) { ?>
                    <h4><?php echo $contact->firstName;?> (<?php echo $contact->lastName;?>)</h4>
          <?php echo $contact->cityName;?>
          <?php
                
}
            } 
?>
Thanks.