请问PHP生成JSON分页问题
最近在搞生成PHP 生成JSON,想实现分页,下边代码已能把数组生成了,分页要怎实现了?想实现每10条分一次页
//connection information
$host = "XXX";
$user = "XXX";
$password = "XX";
$database = "XX";
//make connection
$server = mysql_connect($host, $user, $password);
$connection = mysql_select_db($database, $server);
//query the database
mysql_query('set character set "utf8"');
$query = mysql_query("SELECT * FROM akb order by infoid desc");
//start json object
$json = '{"tags":[';
//loop through and return results
for ($x = 0; $x
$row = mysql_fetch_assoc($query);
$infoid=$row["InfoId"];
$Title=$row["Title"];
$pic=$row["LogoImg"];
$bpic=$row["LogoImg2"];
$time=$row["AccTime"];
$info=$row["Burden"];
$url=$row["ExtUrl"];
$json .= '{"id":"'. $infoid .'","title":"'.$Title.'","pic":"'.$pic.'","bpic":"'.$bpic.'","time":"'.$time.'","info":"'. $info .'","url":"'. $url.'"}';
if ($x
$json .= ",";
else
$json .= "]}";
}
$response = $_GET["callback"] . $json;
echo $response;
//close connection
mysql_close($server);
?>