$TableName = $_POST['TableName'];//表名称
$FieldList = $_POST['FieldList'];//显示列名
$PrimaryKey = $_POST['PrimaryKey'];//主键
$WHERE = $_POST['WHERE'];//查询条件 不含'where'字符
$ORDER = $_POST['ORDER'];//排序 不含'order by'字符,如id asc,userid desc,当@SortType=3时生效
$SortType = $_POST['SortType'];//排序规则 1:正序asc 2:倒序desc 3:多列排序
$RecorderCount = $_POST['RecorderCount'];//记录总数 0:会返回总记录
$PageSize = $_POST['PageSize'];//分页大小
$PageIndex = $_POST['PageIndex'];//页索引
$sql = "CALL P_viewPage('".$TableName."',
'".$FieldList."',
'".$PrimaryKey."',
'".$WHERE."',
'".$ORDER."',
".$SortType.",
".$RecorderCount.",
".$PageSize.",
".$PageIndex.",
@TotalCount,
@TotalPageCount);";
mysql_query($sql,$link);
$res = mysql_query("SELECT @TotalCount;",$link);
$row = mysql_fetch_row($res);
print_r($row);
$FieldList = $_POST['FieldList'];//显示列名
$PrimaryKey = $_POST['PrimaryKey'];//主键
$WHERE = $_POST['WHERE'];//查询条件 不含'where'字符
$ORDER = $_POST['ORDER'];//排序 不含'order by'字符,如id asc,userid desc,当@SortType=3时生效
$SortType = $_POST['SortType'];//排序规则 1:正序asc 2:倒序desc 3:多列排序
$RecorderCount = $_POST['RecorderCount'];//记录总数 0:会返回总记录
$PageSize = $_POST['PageSize'];//分页大小
$PageIndex = $_POST['PageIndex'];//页索引
$sql = "CALL P_viewPage('".$TableName."',
'".$FieldList."',
'".$PrimaryKey."',
'".$WHERE."',
'".$ORDER."',
".$SortType.",
".$RecorderCount.",
".$PageSize.",
".$PageIndex.",
@TotalCount,
@TotalPageCount);";
mysql_query($sql,$link);
$res = mysql_query("SELECT @TotalCount;",$link);
$row = mysql_fetch_row($res);
print_r($row);
$res = mysql_query("SELECT @TotalCount AS TotalCount,@TotalPageCount AS TotalPageCount;",$link);
$clientInfo=array();
while($row = mysql_fetch_array($res))
{
$clientInfo[]=array('TotalCount'=>$row['TotalCount'],'TotalPageCount'=>$row['TotalPageCount']);
}
echo json_encode($clientInfo);
现在代码改变了下,但是出来的结果是:
[{"TotalCount":null,"TotalPageCount":null}]
$res = mysql_query("SELECT @TotalCount AS TotalCount,@TotalPageCount AS TotalPageCount;",$link);
$clientInfo=array();
while($row = mysql_fetch_array($res))
{
$clientInfo[]=array('TotalCount'=>$row['TotalCount'],'TotalPageCount'=>$row['TotalPageCount']);
}
echo json_encode($clientInfo);
’
少个 ‘from 表‘ 吧,你那个数据库语句肯定有问题,或者没有结果集