|
// Set the returned json data
Header ('content-type: application/json; charset = utf8 ');
// Connect to the 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! ");
// Obtain paging parameters
$ Page = 0;
$ PageSize = 3;
If (! Is_null ($ _ GET ["page"]) {
$ Page = $ _ GET ["page"];
}
If (! Is_null ($ _ GET ["pageSize"]) {
$ PageSize = $ _ GET ["pageSize"];
}
// Query data to the array
$ Result = mysql_query ("select username, password from userinfo limit". $ page. ",". $ pageSize ."");
$ Results = array ();
While ($ row = mysql_fetch_assoc ($ result )){
$ Results [] = $ row;
}
// Convert the array to json format
Echo json_encode ($ results );
// Close the connection
Mysql_free_result ($ result );
Mysql_close ($ link );
|