Hello all! well I am want to display two list of values one for categories and one for brands. But, the only the categories are being displayed. If I change the position of the code, for eg put the codes for brands first followed by the categories codes, the brands are being displayed. Can anyone help me? Ive tried almost everything. In index.php <?php $obj = new CategoryList(); if (method_exists($obj, 'init')) { $obj->init(); } for($i = 0;$i< count($obj->mCategory); $i++) { $result[$i] = "<a href=''>" . $obj->mCategory[$i]['name']. "<br/>" . "</a>"; echo $result[$i]; } $obj2 = new BrandList(); if (method_exists($obj2, 'init')) { $obj2->init(); } for($i = 0;$i< count($obj2->mBrand); $i++) { $result[$i] = "<a href=''>" . $obj2->mBrand[$i]['name']. "<br/>" . "</a>"; echo $result[$i]; } ?> Code (markup): Codes for classes: <?php class CategoryList { public $mSelectedCategory = 0; public $mCategory=null; public $mResult; public function __construct() { if (isset ($_GET['category_id'])) $this->mSelectedCategory = (int)$_GET['category_id']; } public function init() { $this->mCategory = Catalog::GetCategory(); $result = Catalog::GetCategory(); } } <?php class BrandList { public $mSelectedBrand = 0;// to store id of selected brand public $mBrand=null; public function __construct() { if (isset ($_GET['brand_id'])) $this->mSelectedBrand = (int)$_GET['brand_id']; } public function init() { $this->mBrand = Catalog::GetBrand(); } } Code (markup):
It would be nice if you would post the both static function or the whole catalog class. Then why did you set the urls in an array and not an variable? And why are the named the same for brands and categories? Why is this row $result = Catalog::GetCategory(); still in your function. You should hold your code clean.