<?php
/*
  $Id: whos_online.php,v 1.32 2003/06/29 22:50:52 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top_output.php');
  
  
  
function soobic_get_Rootcategoryidid($cid) {
	$ocid=$cid;
	$pid=1;
	while ($pid!=0) {
	$psql='select c.categories_id,c.parent_id from categories c where c.categories_id ='.$ocid.' limit 1';
    $p_query = tep_db_query($psql);
    $p_result = tep_db_fetch_array($p_query);
	$pid=$p_result['parent_id'];
	$ocid=$pid;
	if ($pid==0) 
	{
		return $p_result['categories_id'];
	}
	}
}

function soobic_get_parentcategoryid($cid) {
		$psql='select parent_id from categories where categories_id ='.$cid.' limit 1';
		$p_query = tep_db_query($psql);
		$p_result = tep_db_fetch_array($p_query);
		if ($p_result['parent_id']>0)
		{
			return $p_result['parent_id'];
		}
		else
	    return "";		
}
  
  
  $cid=133;
  getAllClassesIdByParentId($cid);
  echo "<br>all cid---------".$allc_id;
  echo "<br>parent cid---------".soobic_get_parentcategoryid($cid);
  echo "<br>root cid---------".soobic_get_Rootcategoryidid($cid);
?>