Welcome Guest, Not a member yet? Register   Sign In
just getting the DB results and View them
#1

[eluser]number1chump[/eluser]
Hello,

well, as simple as the title reads, however, I am not getting it right.

Fatal error: Call to a member function result() on a non-object in C:\xampp\htdocs\site8authentication\application\views\pillaarticuloview.php on line 9

===========================

MODEL (pillaarticulomodel.php)
Code:
<?php

class Pillaarticulomodel extends CI_model {
    
  public $article;
  public $section;
  public $category;
    
    function __construct()
    {
        // Call the Model constructor de Code Igniter
        parent::__construct();
    }
      function get_last_ten_entries()
    {
        $query = $this->db->get('articulos', 10);
        return $query->result();
    }

    
}


?>

CONTROLLER (articulos_controller.php)

Code:
<?php

class Articulos_controller extends CI_Controller {

function pillaarticulos()

    {

$config['hostname'] = "localhost";
$config['username'] = "root";
$config['password'] = "";
$config['database'] = "noticias";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;




        $this->load->model('Pillaarticulomodel', '', $config);

        $data['query'] = $this->pillaarticulomodel->get_last_ten_entries();

        $this->load->view('pillaarticuloview', $data);
    }
        
        
        
        
    
      
    }



}

?>

AND VIEW (pillaarticuloview.php)

Code:
<?php
  
foreach ($query->result() as $row)
   {
      echo $row->section;
      echo $row->category;
      
   }





?>




Theme © iAndrew 2016 - Forum software by © MyBB