Welcome Guest, Not a member yet? Register   Sign In
DataMapper CodeIgniter - Dropdown list
#1

[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.


Messages In This Thread
DataMapper CodeIgniter - Dropdown list - by El Forum - 05-25-2013, 07:08 AM
DataMapper CodeIgniter - Dropdown list - by El Forum - 05-26-2013, 05:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB