Welcome Guest, Not a member yet? Register   Sign In
Show database results in a table
#9

[eluser]karltingume2007[/eluser]
hey guys!!!

initially i was not part of this problem and solution on showing database results in a table but i was following up closely because i was working on something similar. i have a problem on loading the content of my database unto my view. here is my code:

The controller:
Code:
class Addressbook extends CI_Controller {

public function __construct() {
parent::__construct();
  }
  
public function index() {
$query = "select * from contacts";
    $data['results'] = $this->db->query("$query");
$this->load->view('addressbook_view', $data);

The view:
Code:
<?php

foreach ($results->result() as $row)
  {
    echo $row;  
}
?>

A function in my model:
Code:
function get_entries() {
$query = $this->db->get('contacts');
return $query->result();
}

all of these bring me the following error:
Code:
A PHP Error was encountered

Severity: 4096

Message: Object of class stdClass could not be converted to string

Filename: views/addressbook_view.php

Line Number: 90

please somebody tell me how to convert an object of a class into a string or better still an advanced solution to this problem or how to go about it. Thank you all in advance.




Messages In This Thread
Show database results in a table - by El Forum - 11-20-2009, 10:28 PM
Show database results in a table - by El Forum - 11-20-2009, 11:10 PM
Show database results in a table - by El Forum - 11-21-2009, 12:18 AM
Show database results in a table - by El Forum - 11-21-2009, 01:27 AM
Show database results in a table - by El Forum - 11-21-2009, 08:43 AM
Show database results in a table - by El Forum - 11-21-2009, 10:29 AM
Show database results in a table - by El Forum - 11-21-2009, 07:02 PM
Show database results in a table - by El Forum - 11-22-2009, 06:58 AM
Show database results in a table - by El Forum - 09-28-2012, 07:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB