欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

作用循环读取某栏目下的所有子栏目。

程序员文章站 2022-05-16 11:42:08
...
php代码:
<?php
//网站导航栏目id
class navigation
{
	var $class;
	var $classstr = "";
	
	function __construct($id)
	{
		$this->class = $id;
	}
	
	function ishave($id)
	{
		global $myobj,$language;
		$sql = "select * from cy_{$language}_sitecategory where did = ".$id;
		$result = $myobj->getRowsRst($sql);
		return $result;
	}
	
	function subclass($id)
	{
		global $myobj,$language;
		$sql = "select * from cy_{$language}_sitecategory where did = ".$id;
		$rs = $myobj->query($sql);
		while($rt = $myobj->getarray($rs))
		{
			$classstr .= $rt['id'].', ';
		}
		return $classstr;
	}	
	
	function classname()
	{
		global $myobj,$language;
		$tmpstr = "";
		$sql = "select * from cy_{$language}_sitecategory where did = ".$this->class;
		$rs = $myobj->query($sql);
		while($rt = $myobj->getarray($rs))
		{
			if($this->ishave($rt['id']))
			{
				$tmpstr = $this->subclass($rt['id']);
			}
			$classstr .= $rt['id'].', ';
		}
		return empty($tmpstr)?$classstr:$classstr.$tmpstr;
	}
	
}


?>