Welcome Guest, Not a member yet? Register   Sign In
Confusion with MVC in CI
#3

[eluser]ChaosKnight[/eluser]
Thanks, I changed my code to this now:
Model:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  class Countries_model extends Model
  {
    function Countries_model()
    {
      parent::Model();
    }
    function getCountries()
    {
      $this->load->database();
    
      $this->db->select('country_id','country');
      $query = $this->db->get('countries');
      return $query;
    }
  }
/* End of Countries.php model */
Controller:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

  class Countries extends Controller
  {
    function Countries()
    {
      parent::Controller();
      $this->load->helper('html');
      $this->load->helper('url');
      $this->load->model('countries_model');
    }
    function index()
    {
      $query = $this->countries_model->getCountries();

      $data['page_title'] = 'Countries';

      $this->load->view('header',$data);
      $this->load->view('nav');
      $this->load->view('sidebar');
      $this->load->view('countries',$query);
      $this->load->view('footer');
    }
  }
/* End of Countries.php controller */
View:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
?>
<div id="content">
  &lt;?php
  foreach ($query->result() as $row)
  {
    echo $row->country;
  }
  ?&gt;

</div>
&lt;?php
/* End of Countries.php view */
I'm not sure if this is correct, but it still just returns a blank screen... I'm a bit disappointed in myself, because since I started with CI yesterday, only the few tutorials in the user guide that I tried have worked... None of my own code has worked so far :-S


Messages In This Thread
Confusion with MVC in CI - by El Forum - 06-16-2010, 07:05 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 07:26 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 07:40 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 07:45 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 07:57 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 07:59 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 08:09 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 08:48 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 09:01 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 09:18 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 09:23 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 09:28 AM
Confusion with MVC in CI - by El Forum - 06-16-2010, 12:07 PM
Confusion with MVC in CI - by El Forum - 06-16-2010, 01:15 PM
Confusion with MVC in CI - by El Forum - 06-16-2010, 01:35 PM
Confusion with MVC in CI - by El Forum - 06-16-2010, 02:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB