$sql = "select typeid,name,fid from productstype where fid=0 and ctid=$pro_ctid order by sortid asc,typeid desc";
SQL($sql);
while($rs = TOP())
{
?>
$sql = "select * FROM products where ctid=$pro_ctid and typeid in(select typeid from productstype where typeid=".$rs['typeid']." or fid=".$rs['typeid'].") order by sortid,id desc";
SQL2($sql);
$rs2 = TOP2();
?>
echo $rs['name']?>
$sql = "select * FROM products where ctid=$pro_ctid and typeid=".$rs['typeid']." order by sortid,id desc";
SQL2($sql);
while($rs2 = TOP2())
{
?>
echo $rs2['name'];?>
STEP2();
}
?>