Home > php教程 > PHP源码 > 作用循环读取某栏目下的所有子栏目。

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

PHP中文网
Release: 2016-05-25 17:00:08
Original
1136 people have browsed it

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[&#39;id&#39;].&#39;, &#39;;
		}
		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[&#39;id&#39;]))
			{
				$tmpstr = $this->subclass($rt[&#39;id&#39;]);
			}
			$classstr .= $rt[&#39;id&#39;].&#39;, &#39;;
		}
		return empty($tmpstr)?$classstr:$classstr.$tmpstr;
	}
	
}


?>
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template