我有一个表,其中3行的there.each数据是不同的。我试图在HTML表中显示完整的数据库表,但是它显示了一个数据3次。
$query=mysqli_query($db,"SELECT entrydate,day,discription,highlight,place from datatable");
$insert=mysqli_fetch_array($query);
$countrow=mysqli_num_rows($query);这是显示表的代码..。
<?php
If ($countrow > 0) {
for($i=0;$i<$countrow;$i++) {
?>
<tr>
<td><?php echo $insert['entrydate']; ?></td>
<td><?php echo $insert['day']; ?></td>
<td><?php echo $insert['discription']; ?></td>
<td><?php echo $insert['highlight']; ?></td>
<td><?php echo $insert['place']; ?></td>
<td>
<a href="#" class="btn btn-sm btn-primary glyphicon glyphicon-pencil"></a>
<a href="#" class=" btn btn-sm btn-danger glyphicon glyphicon-remove"></a>
</td>
</tr>
<?php
}
}
?>我的输出是输出
发布于 2017-04-23 19:13:51
你需要移除:
$insert=mysqli_fetch_array($query);然后将for循环更改为while循环:
while ($insert=mysqli_fetch_array($query)) {这将导致在每个循环中使用每个结果填充$insert,直到没有任何结果保留。
https://stackoverflow.com/questions/43575327
复制相似问题