所以我必须解析一大堆数据,这些数据被格式化为JSON,存储在数据库中。
require_once('db.php');
error_reporting(1);
$getUsers = mysqli_query($db, 'SELECT * FROM mcmmo_users LIMIT 300');
$rows = array();
while ($r = mysqli_fetch_assoc($getUsers))
{
$skills = array();
$tempRow = $r;
$getSkills = mysqli_query($db, "SELECT * FROM mcmmo_skills WHERE user_id = '" . $r['id'] . "' LIMIT 300");
while ($r = mysqli_fetch_assoc($getSkills))
{
unset($r['id']);
$skills[] = $r;
}
$tempRow['skills'] = $skills;
$rows[] = $tempRow;
}
header('Content-Type: application/json');
echo json_encode($rows);
哪个输出:
[{"id":"1","user":"user1","lastlogin":"1402936307","skills":[{"user_id":"1","taming":"4","mining":"534","woodcutting":"84","repair":"26","unarmed":"0","herbalism":"108","excavation":"219","archery":"10","swords":"75","axes":"24","acrobatics":"74","fishing":"403","alchemy":"0"}]}
但超过15,000条记录。
我想使用AngularJS创建一个单页面应用程序。到目前为止我有这个:
require_once('db.php');
error_reporting(1);
$getUsers = mysqli_query($db, 'SELECT * FROM mcmmo_users LIMIT 300');
$rows = array();
while ($r = mysqli_fetch_assoc($getUsers))
{
$skills = array();
$tempRow = $r;
$getSkills = mysqli_query($db, "SELECT * FROM mcmmo_skills WHERE user_id = '" . $r['id'] . "' LIMIT 300");
while ($r = mysqli_fetch_assoc($getSkills))
{
unset($r['id']);
$skills[] = $r;
}
$tempRow['skills'] = $skills;
$rows[] = $tempRow;
}
header('Content-Type: application/json');
echo json_encode($rows);
的index.html:
<table class="table table-striped" ng-controller="mcmmoCtrl">
<tr>
<th>Player</th>
<th>Taming</th>
</tr>
<tr ng-repeat="stats in mcmmo">
<td>{{ stats.user }}</td>
<td>{{ stats.skills[0].taming }}</td>
</tr>
</table>
除非我限制数据,否则在视图中查看任何内容都需要5分钟以上。我希望有一种简单的方法可以“翻页”这个,这样我就可以点击“更多”按钮,或第1,2页,而无需更改页面。
我该怎么做?