Codeigniter: Retrieving data from multiple tables and displaying results?

I don't know whats in your model but if you try something like $this->db->from('property'); $this->db->join('branch', 'branch. Id = property.Id') You can put a where statement in there too if you need something particular This means you have a more complex model but less loops and arrays and messy stuff in the view which is what you want.

I don't know whats in your model but if you try something like $this->db->from('property'); $this->db->join('branch', 'branch. Id = property.Id'); You can put a where statement in there too if you need something particular. This means you have a more complex model but less loops and arrays and messy stuff in the view which is what you want.

Yes, currently you're just getting one or the other. You're probably better to put it into a multilevel array like $data'property''prop'.

And do I always have to have a foreach loop. In this case I know there will only be one result returned. Seems daft to have a loop in there – Craig Ward Jun 8 '10 at 12:20 First off, you never "know" that only one result will be returned unless you put a LIMIT 0,1 on it.

Second, why are you using a foreach loop then? Shouldn't your ManageProperty_model take care of that and simply return the object so you can say $prop->id, $img->image_link, etc?– Josh K Jun 8 '10 at 13:55.

I am developing my first big application using codeigniter and need a little help as I am fairly new to it all. I know how to get records out of the DB and display them, but I now have to get results from two tables and display them. I pass $data to the view, it works fine for $data'prop' but I can't get the rest.

Php foreach ($prop as $p) :? Php echo $p->ID;?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions