Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ID Item_id
- 1 1
- 2 2
- 3 3
- 4 4
- 5 5
- ID Item_id Category
- 1 1 cat1
- 2 2 cat1
- 3 2 cat2
- 4 3 cat2
- 5 3 cat3
- 6 3 cat4
- 7 4 cat2
- 8 5 cat1
- etc.
- Category_id category_name
- cat1 apples
- cat2 oranges
- cat3 bananas
- cat4 pineapples
- public function getCategories(){
- $this->db->query('SELECT table1.*, table2.*, table3.*
- FROM table1
- INNER JOIN table2
- ON table1.item_id = table2.item_id
- INNER JOIN table3
- ON table2.category=table3.category_id');
- $results = $this->db->resultset();
- return $results;}
- $items = $offer_class -> getCategories();
- <?php foreach($items as $item){
- echo $item->category_name;
- }
- ?>
Add Comment
Please, Sign In to add comment