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

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

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

	$conn_getpass=@mysqli_connect($getpasshost,$getpassusername,base64_decode($getpasspassword)) or die ("can't connect DBS ".$getpasshost.",".$getpassusername);
	mysqli_select_db($conn_getpass,$getpassdbname);
	mysqli_set_charset($conn_getpass,"utf8");
	
	$sqlstr = $_GET['sqlstr'];
	$table = $_GET['table'];
	$iftext = $_GET['iftext'];

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

		while($fiels_rows=mysqli_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);  



?>