| Sets the return JSON format data Header (' Content-type:application/json;charset=utf8 '); Connecting to a database $link = mysql_connect ("localhost", "root", "root") or Die ("Unable to connect to the mysql!"); mysql_query ("SET NAMES ' UTF8 '"); mysql_select_db ("Jilinwula", $link) or die ("Unable to connect to the mysql!"); Get Paging parameters $page = 0; $pageSize = 3; if (!is_null ($_get["page"])) { $page = $_get["page"]; } if (!is_null ($_get["PageSize")) { $pageSize = $_get["PageSize"]; } Querying the data into the array $result = mysql_query ("Select Username,password from UserInfo limit". $page. ", ". $pageSize. ""); $results = Array (); while ($row = Mysql_fetch_assoc ($result)) { $results [] = $row; } Convert an array to JSON format echo Json_encode ($results); Close connection Mysql_free_result ($result); Mysql_close ($link); |