<?php
class Ajaxpersonal
{
	function Ajaxpersonal()
	{
		//var_dump($_REQUEST);
	}
	
	function geInfo()
	{
		$mval = $this -> input ->  delUrl($_REQUEST["m"]);
		$sval = $this -> input ->  delUrl($_REQUEST["s"]);
		$namval = $_REQUEST["nam"];
		$info = array();
		switch ($mval)
		{
			case 'artlist':
				//查询分类
				$sql_query = " SELECT ars_id as id ,ars_name as name ,ars_parentid as parentid  FROM  ".$this -> db -> prefix."artsort  WHERE 1 GROUP BY ars_id ORDER BY ars_list,`ars_id` LIMIT 0,1000 ";
				$infosm   = $this -> db -> select_info($sql_query);

				break;
			case 'prolist':
				//查询分类
				$sql_query = " SELECT prs_id as id ,prs_name as name ,prs_parent_id as parentid  FROM  ".$this -> db -> prefix."prosort  WHERE 1 GROUP BY prs_id ORDER BY prs_list,`prs_id` LIMIT 0,1000 ";
				$infosm   = $this -> db -> select_info($sql_query);

				break;
			case 'piclist':
				$sql_query = " SELECT pis_id as id ,sort_name as name ,pis_parentid as parentid  FROM  ".$this -> db -> prefix."picsort  WHERE 1 GROUP BY pis_id ORDER BY pis_list,`pis_id` LIMIT 0,1000 ";
				$infosm   = $this -> db -> select_info($sql_query);

				break;
				
			case 'vidlist':
				$sql_query = " SELECT vis_id as id ,vis_name as name ,vis_parentid as parentid  FROM  ".$this -> db -> prefix."vidsort  WHERE 1 GROUP BY vis_id ORDER BY vis_list,`vis_id` LIMIT 0,1000 ";
				$infosm   = $this -> db -> select_info($sql_query);

				break;
			
			case 'invlist':
				
				break;	
			
			case 'votlist':
				
				break;
			case 'dowlist':
				$sql_query = " SELECT dos_id as id ,dos_name as name ,dos_parentid as parentid  FROM  ".$this -> db -> prefix."dowsort  WHERE 1 GROUP BY dos_id ORDER BY dos_list,`dos_id` LIMIT 0,1000 ";
				$infosm 		= $this -> db -> select_info($sql_query);
				break;
				
			default :
				exit();
		}
		
		foreach ((array)$infosm as $rowkey => $rowval)
		{
				if($rowval["parentid"] == 0)
				{
						
					$info[$rowval["id"]]['id'] 		 = $rowval["id"] ;
					$info[$rowval["id"]]['name'] 	 = $rowval["name"] ;
					$info[$rowval["id"]]['parentid'] = $rowval["parentid"] ;

				}else{
					$info[$rowval["parentid"]]['array'][] = $rowval;	
				}
		}
		if($namval!=''){
			echo '<select name="'.$namval.'" id="'.$namval.'">';
		}else{
			echo '<select name="s" id="s">';
		}
		echo '<option value="">请选择</option>';
		
		foreach((array)$info as $ikey => $ival )
		{
			if($ival["id"]==$sval)
			{
				echo '<option value="'.$ival["id"].'" selected = "selected" >'.$ival["name"].'</option>';
			}else{
				echo '<option value="'.$ival["id"].'" >'.$ival["name"].'</option>';
			}
			foreach((array)$ival["array"] as $iakey => $iaval)
			{
				if($iaval["id"]==$sval){
					echo '<option value="'.$iaval["id"].'" selected = "selected" >&nbsp;&nbsp;'.$iaval["name"].'</option>';
				}else{
					echo '<option value="'.$iaval["id"].'">&nbsp;&nbsp;'.$iaval["name"].'</option>';
				}
			}
			
		}
		echo '</select>';
		
	
	}
}

$Ajaxpersonal = new Ajaxpersonal();


?>