function productRightMenuList()
{
# Get parent (main) categories parent_id=0;
$rsMain = mysql_query("SELECT id, parent_id, name FROM collections WHERE parent_id=0") or die(mysql_error());
$category = $arrprod=array();
if(mysql_num_rows($rsMain) >= 1)
{
while($rows_main = mysql_fetch_assoc($rsMain))
{
if($rows_main['id'] == 5 || $rows_main['id'] == 20 || $rows_main['id'] == 23)
{
$pro = "SELECT id,name FROM products where collection_id='".$rows_main['id']."' ORDER by ordering";
}
else
{
$pro = "SELECT id,name FROM products where collection_id=".$rows_main['id'];
}

$sql = mysql_query($pro) or die(mysql_error());
if(mysql_num_rows($sql) >=1)
{
$arrprod="";
while($fetch = mysql_fetch_assoc($sql))
{
//echo "prodcuts-->".$fetch['name']; echo "<br>";
$arrprod[$fetch['id']]=$fetch['name'];
}
$category[$rows_main['name']][$rows_main['id']]=$arrprod;
}
$m=$this->showSubCategories($rows_main['id']);
if(count($m) == 0) { }
else
{
$category[$rows_main['name']][$rows_main['id']]= $this->showSubCategories($rows_main['id']);
}

}
}
//echo '<pre>';
//print_r($category);exit;
$data['content'] = json_encode($category);
$this->load->view('blank', $data);
}

Advertisements