I am trying to get the following:
Cat1
Product1
Product2
Cat2
Product3
Product4
etc etc.
[php]<?PHP
$sql = "
SELECT DISTINCT
JVPCX.category_id
,
JVP.product_id
,
JVP.product_sku
,
JVP.product_s_desc
FROM
jos_vm_product_category_xref
JVPCX
INNER JOIN jos_vm_product
JVP
ON JVPCX.product_id
= JVP.product_id
";
$res = mysql_query($sql);
$list = array();
while ( $r = mysql_fetch_object( $res ) )
{
if ( ! isset( $list[ $r->category_id ] ) )
{
$list[ $r->category_id ] = array();
}
$list[ $r->category_id ][ $r->product_id ] = array(
'SKU' => $r->product_sku,
'Description' => $r->product_s_desc,
);
}
?>
[/php]
print_r($list):
Array ( [5] => Array ( [1] => Array ( [SKU] => EASY819-AC-RC [Description] => ) [3] => Array ( [SKU] => EASY819-DC-RC [Description] => ) [2] => Array ( [SKU] => EASY819-AC-RCX [Description] => ) ) [6] => Array ( [4] => Array ( [SKU] => EASY719-AB-RC [Description] => ) [5] => Array ( [SKU] => EASY719-AB-RCX [Description] => ) ) )
Just can’t seem to get this working, any advice would be fantastic. Thanks in advance.