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

[eluser]Dam1an[/eluser]
What do you get when you use print_r on the query

Try both the following
Code:
$query = $this->db->get('questions');
echo 'Query:<br />';
print_r($query);
echo '<br /><br /><br /><br />';
echo 'Results:<br />';
$results = $query->result();
print_r($results);
#12

[eluser]Nicholas Hanks[/eluser]
I think problem is in your DB config file password is missing!!!!! for root user.
#13

[eluser]Dam1an[/eluser]
[quote author="Nicholas Hanks" date="1240875575"]I think problem is in your DB config file password is missing!!!!! for root user.[/quote]

Thats normal assuming he's using XAMPP/WAMP/MAMP etc as they all have the root with no password, they aim to be as open as possible for development, not secure for a production system
#14

[eluser]Mark Skilbeck[/eluser]
Shouldn't it be:
Code:
$data['questions'] = $this->db->get('questions');

Code:
foreach($questions->result() as $question)
{
    // Etc.
}
#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;}?&gt;
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;
}?&gt;

Hope it will help.
Cheers




Theme © iAndrew 2016 - Forum software by © MyBB