【发布时间】:2017-08-09 05:14:24
【问题描述】:
试图显示一个包含 150 多个条目但仅显示 61 个条目的表格,我如何让所有条目无限期地显示在页面上或添加“页面”功能以便我们可以浏览所有条目,而不仅仅是最多 61 个条目?
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Posting Info</h1>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Post Info Table
</div>
<div class="panel-body">
<div class="row-sm-4">
<div class="col-lg-6" style="width: 100% !important;">
<form role="form" style="width: 100% !important;">
<div class="table-responsive" style="width: 100% !important;">
<table class="table table-bordered table-striped" style="width: 100% !important;">
<thead>
<tr>
<th>Example1</th>
<th>Example2</th>
<th>Example3</th>
<th>Example4</th>
<th>Example5</th>
<th>Example6</th>
<th>Example7</th>
<th>Example8</th>
</tr>
</thead>
<tbody>
<?php
$postList = '';
$q = $db->prepare("SELECT * FROM `examples`");
$q->execute();
$q = $q->fetchAll();
foreach ($q as $post)
{
$postList .= '<tr> <td>'.$post['exmpl1'].'</td>
<td>'.$post['exmpl2'].'</td>
<td>'.$post['exmpl3'].'</td>
<td><a href="../'.$post['exmpl4'].'">Click to View</a></td>
<td>'.$post['exmpl5'].'</td>
<td>'.$post['exmpl6'].'</td>
<td>'.$post['exmpl7'].'</td>
<td>'.$post['exmpl8'].'</td>
</tr>';
}
print $postList;
?>
</tbody>
</table>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
目前最多只能显示 61 个条目,但条目中的所有信息都可以正确显示。该代码有效,但似乎受到限制。我正在寻找消除此限制的方法。
【问题讨论】:
-
向示例表中添加更多记录 :)
-
数据库中有 137 条记录,但只有 61 条被放入该表中。这就是问题:(
-
找到数组 $q 的长度,所以你应该找到查询返回的确切值
标签: php sql database html-table