[eluser]Unknown[/eluser]
I want to have a dropdown list with brands, and depending on the choice, it will appear the products of the brand selected.
My Tables
Code:
Brands
==================
id | Brand
---------------
1 Apple
2 Android
Code:
Products
========================================================================
id | Name | Price | Image | Category | Brand_id
------------------------------------------------------------------------------
1 Macbook Air 1000 mac1.jpg computer 1
2 Macbook Pro 1500 mac2.jpg computer 1
3 Android S3 400 s3.jpg mobile 2
My Models
Brands.php
Code:
<?
class Brands extends DataMapper {
var $table = 'brands';
var $has_many = array('Products');
}
?>
Products.php
Code:
<?
class Products extends DataMapper {
var $table = 'products';
var $has_one = array('Brands');
}
?>
My Controller
ListBrands.php
Code:
<?
class ListBrands extends CI_Controller {
function __construct() {
parent::__construct();
}
function index() {
$this->load->view('listbrands_view');
}
}
?>
I don't know if my controller or models are correctly and also I don't know how to do what I'm asking for, a dropdown that will print the products of the brand selected.