Welcome Guest, Not a member yet? Register   Sign In
Database results will not display. New to CI
#15

[eluser]Zeeshan Rasool[/eluser]
Here , two situations arrive ,
When you are using like this in controller. You're getting record directly in controller such as..

Code:
1- $data['questions'] = $this->db->get('questions');

Then record will be accessed in the view with this :

Code:
foreach($questions->result() as $rec){echo $rec->name;}?>
But if you're using model in middle which is models work to do, such as
in controller:
Code:
2- $data['questions'] = $this->model_name->func_name();
and in model:
Code:
func_name()
{
  $query = $this->db->get('questions');
  /// Here you will return query record like this:
  retutn $query->result();
}
Now in the last in view we will get records :
Code:
foreach($questions as $rec)
{
  echo $rec->name;
}?>

Hope it will help.
Cheers


Messages In This Thread
Database results will not display. New to CI - by El Forum - 04-25-2009, 10:00 AM
Database results will not display. New to CI - by El Forum - 04-25-2009, 10:29 AM
Database results will not display. New to CI - by El Forum - 04-25-2009, 11:19 AM
Database results will not display. New to CI - by El Forum - 04-25-2009, 12:37 PM
Database results will not display. New to CI - by El Forum - 04-25-2009, 12:43 PM
Database results will not display. New to CI - by El Forum - 04-25-2009, 06:10 PM
Database results will not display. New to CI - by El Forum - 04-26-2009, 04:46 AM
Database results will not display. New to CI - by El Forum - 04-26-2009, 12:34 PM
Database results will not display. New to CI - by El Forum - 04-26-2009, 12:36 PM
Database results will not display. New to CI - by El Forum - 04-26-2009, 12:37 PM
Database results will not display. New to CI - by El Forum - 04-26-2009, 12:47 PM
Database results will not display. New to CI - by El Forum - 04-27-2009, 12:39 PM
Database results will not display. New to CI - by El Forum - 04-27-2009, 01:17 PM
Database results will not display. New to CI - by El Forum - 04-27-2009, 03:10 PM
Database results will not display. New to CI - by El Forum - 04-27-2009, 10:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB