我有2个表,我在一个SQL查询中加入。然后我为每个表拉一次该sql查询,并将其限制在前10个结果中
我试图通过限制提取的数据量来对查询进行分页,但这会破坏我的表输出。
这是当前代码
<?php
$a = 1;
$b = 1;
for( $i = 0; $i < 300; $i++){
$sql = "SELECT player.ID, player.Login, localrecord.map_id , localrecord.score FROM player JOIN localrecord ON player.ID = localrecord.Player_Id WHERE map_id = $a Order By score ASC LIMIT 10";
$result = $conn->query($sql);
$sql2 = "SELECT file FROM map WHERE ID = $a";
$mapName = $conn->query($sql2);
$mapNamerow = $mapName->fetch_assoc();
if ($result->num_rows > 0) {
// output data of each row
$WRQuery = "SELECT time_author FROM map WHERE ID =$a";
$WRResults = $conn->query($WRQuery);
$WRrow = $WRResults->fetch_assoc();
$WRtime = $WRrow['time_author'];
$WRmilliseconds = $WRtime % 1000;
$WRtime = floor($WRtime / 1000);
$WRseconds = $WRtime % 60;
$WRtime = floor($WRtime / 60);
$WRminutes = $WRtime % 60;
$WRtime = floor($WRtime / 60);
echo "<p class='mapTitle'> " . substr($mapNamerow['file'],11);
echo "<br/>Author's Time: " . $WRminutes . ":". $WRseconds.".". $WRmilliseconds . "</p>";
echo "<table border='1'>
<tr>
<th>Name</th>
<th>Score <br/> Min:Sec.Mil</th>
</tr>";
while($row = $result->fetch_assoc()) {
$time = $row['score'];
$milliseconds = $time % 1000;
$time = floor($time / 1000);
$seconds = $time % 60;
$time = floor($time / 60);
$minutes = $time % 60;
$time = floor($time / 60);
echo "<tr>";
echo "<td>" . $row['Login'] . "</td>";
echo "<td>" . $minutes.':'.$seconds.'.'.$milliseconds . "</td>";
echo "</tr>";
}
echo "</table>";
echo "<br/>";
}
$a++;
}
?>
millisecond-tm-121.Gbx
Author's Time: 0:14.344
Name Score Min:Sec.Mil
mattman0123 0:18.309
millisecond-tm-107.Gbx
Author's Time: 0:16.966
Name Score Min:Sec.Mil
mattman0123 0:17.202
这是当前的输出;
我大约要显示200个表,但我不希望它们一次显示所有表。
有什么想法吗?