<?php
// ajax 调用的获取某一表的sql的一行或多行json
// ls.js: getjson(sqlstr) 
// 返回 除 id, enable, num的json

	include 'conn_var.php';  // getpass 变量

	$returnjson='{"myjson":[';

	$conn_getpass=@mysql_connect($getpasshost,$getpassusername,base64_decode($getpasspassword)) or die ("can't connect DBS ".$getpasshost.",".$getpassusername);
	mysql_select_db($getpassdbname,$conn_getpass);
	mysql_query("SET character_set_client = utf8",$conn_getpass);
	mysql_query("SET character_set_results = utf8",$conn_getpass);
	mysql_query("SET character_set_connection = utf8",$conn_getpass);	

	$sqlstr = $_GET['sqlstr'];
	$table = $_GET['table'];
	$iftext = $_GET['iftext'];

	$select_query1=mysql_query($sqlstr,$conn_getpass);
	while($select_rows=mysql_fetch_assoc($select_query1))
	{
		$resultfiedls= mysql_query("SHOW FULL COLUMNS FROM $table");
		$returnjson.="{";

		while($fiels_rows=mysql_fetch_row($resultfiedls))  //获得字段
		{			
			$fieldname=$fiels_rows[0];
			$fieldtype=$fiels_rows[1];
			 if($fieldname!='ID' and $fieldname!='enable' and $fieldname!='Num' ）//排除字段
			{
				if($fieldtype!="TEXT" || $fieldtype=="TEXT" && $iftext=="true" )
				{
					$returnjson.='"'.$fieldname.'":"'.$select_rows[$fieldname].'",';
				}
			}
		}
		$returnjson.="},"; 

	}
	substr($returnjson,0,(strlen($returnjson)-1)); //去掉最后一个,
	$returnjson.="]}"; 
	
	print_r($returnjson);  



?>