Welcome Guest, Not a member yet? Register   Sign In
HELP: Can't Display Data
#1

Hi. I am very new to CodeIgniter and I am using v2.2.3.
I managed to create the following code but I am unable to display the data.

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

class Item_Model extends CI_Model {
      function __construct() {
        parent::__construct();
        
    }


    // Fetch data according to per_page limit.
    public function fetch_data($id) {
        $this->db->where('id', $id);
        $query = $this->db->get('items');
        if($query->num_rows()!==0)
        {
            return $query->result();
        }
        else
            return FALSE;
   }
}
?>


Here is my Controller
Code:
function item()
    {
        if($this->session->userdata('logged_in'))
           {          
               
          
            $data["results"] = $this->item_model->fetch_data($id);          


                   $session_data = $this->session->userdata('logged_in');
                   $data['username'] = $session_data['username'];  
                $data['title'] = '';
                $this->load->view('inventory/item_view', $data);
         }
         else
       {
               $this->session->set_flashdata('message', 'Oops! You have to Login');
         //If no session, redirect to login page
             redirect('login', 'refresh');
       }

    }


I am unable to display data by getting the ID.
I hope anyone can help
Reply


Messages In This Thread
HELP: Can't Display Data - by Maaacoooo - 07-27-2015, 09:52 AM
RE: HELP: Can't Display Data - by mwhitney - 07-27-2015, 10:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB