Welcome Guest, Not a member yet? Register   Sign In
Data from database not showing up
#3

[eluser]khagendra[/eluser]
Here is your model code
Code:
//getShows Function
function getShows()
{
    //Get Shows Data
    $this->db->get('shows');    
}

Your function getShows just retrieving the data from database but returning no result. So you have to add one more line like this
Code:
//getShows Function
function getShows()
{
    //Get Shows Data
    $query = $this->db->get('shows');
    return $query->result();
}

-- You also have to load the model in ur controller. if the class name of model is Model_name then u can load like this
Code:
class ControllerName extends Controller
{
    function ControllerName()
    {
       parent::Controller();
       $this->load->model('Model_name');
    }
}

to fetch the data, within any function of that controller u can write like this
Code:
$this->Model_name->getShows();

The data will be return as array of objects. so u can write like this
Code:
$data['show_info'] = $this->Model_name->getShows();

Finally, the fields name can be fetched as in ur view like this
Code:
$show_info->field_name;

Note: use the same name of loaded model while fetching the model function. Here is example
Code:
$this->load->model('Model_name');
    then use like this
    $this->Model_name->getShows();
    $this->model_name->getShows() // this will be wrong
  
    OR
    $this->load->model('model_name');
    $this->model_name->getShows();
    $this->Model_name->getShows() // this will be wrong
Hope this will help you solving your problem.


Messages In This Thread
Data from database not showing up - by El Forum - 10-23-2009, 08:55 PM
Data from database not showing up - by El Forum - 10-23-2009, 10:30 PM
Data from database not showing up - by El Forum - 10-23-2009, 10:48 PM
Data from database not showing up - by El Forum - 10-24-2009, 09:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB