PHP/数据库表循环-一次仅显示15行 [英] PHP/database table loop - display only 15 rows at time
本文介绍了PHP/数据库表循环-一次仅显示15行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个要通过PHP编辑显示的数据库.在主页上,我只想显示表格的前15行,然后让用户单击以生成更多表格行.
I have a database I'm trying to display for edit through PHP. On the main page I want to show only the first 15 rows of the table then have the user click to generate more table rows.
<?php
include('../config.php');
$result = $mysqli->query("SELECT uid, title, description, tblFacilityHrsDateTimes.* FROM tblFacilityHrs LEFT JOIN tblFacilityHrsDateTimes ON tblFacilityHrs.uid = tblFacilityHrsDateTimes.owner_uid ORDER BY tblFacilityHrs.title") or die($mysqli->error);
while($row =$result->fetch_assoc()){
extract ($row);
echo "<tr>";
echo "<td> {$id} </td>"; //hide when finished
echo "<td> {$title} </td>";
echo "<td> {$description} </td>";
echo "<td> {$startEventDate} </td>";
echo "<td> {$endEventDate} </td>";
echo "<td> {$startTime} </td>";
echo "<td> {$endTime} </td>";
echo "<td> {$days} </td>";
echo "<td> {$recurrence} </td>";
echo "<td> {$finalDate} </td>";
echo "<td>";
echo "<a class=\"buttons\" href=edit.php?id={$id}&uid={$uid}>Edit</a><span class='icon'></span></a>
";
echo " / ";
echo "<a class=\"buttons\" href='javascript: Confirm()'>Delete</a>";
echo "</td>";
echo "</tr>";
echo "</div>";
}
echo "</table>";
$result->free();
$mysqli->close();
?>
推荐答案
可能您正在寻找分页,可以通过mysql LIMIT
Probably you are looking for Pagination, this can be done through mysql LIMIT
类似的东西
$result = $mysqli->query("SELECT uid, title, description, tblFacilityHrsDateTimes.* FROM tblFacilityHrs LEFT JOIN tblFacilityHrsDateTimes ON tblFacilityHrs.uid = tblFacilityHrsDateTimes.owner_uid ORDER BY tblFacilityHrs.title LIMIT 15, $page ")
$ page用于偏移
Where $page is for offset
这里有一些用于创建自定义分页的教程
Here are few tutorial for creating custom pagination
这篇关于PHP/数据库表循环-一次仅显示15行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文