[eluser]Firestorm ZERO[/eluser]
I'm a bit rusty on mysql. So need some help with the following example...
Book
id
name
publisher - id from publisher table
author - id from author table
Publisher
id
name
Author
id
name
To list all books I would do a join right? So in my Model I have the following...
Code:
$this->db->select('*');
$this->db->from('book');
$this->db->join('publisher', 'book.publisher = publisher.id');
$this->db->join('author', 'book.author = author.id');
$this->db->order_by('title');
Which I believe is right (not sure). Now to print it, in my view I have...
Code:
<?php foreach ($query->result() as $row): ?>
<tr>
<td><?= $row->title ?></td>
<td><?= $row->name ?></td>
<td><?= $row->publisher ?></td>
<td><?= $row->author ?></td>
</tr>
<?php endforeach; ?>
Now the problem is how do I print the Publisher and Author names? Since the column name is the same for all 3 tables?
I'm using CI v1.5.4.