[英]PHP/MySQL output into table with bootstrap - columns are messed
我在将mysql输出到表中时遇到问题。 脚本运行良好,我得到了所需的数据,但表中的列混乱了。 似乎这些多重回声可能存在问题,但是我尝试了发现/想到的每种可能的组合,但到目前为止没有任何效果。
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo"<table class='table table-hover table-striped table-responsive'>";
echo"<tr class='table_row'>";
echo"<td>" . $row['1'] . "</td>";
echo"<td>" . $row['2'] . "</td>";
echo"<td>" . $row['3'] . "</td>";
echo"<td>" . $row['4'] . "</td>";
echo"<td><a href='#'><button type='button' class='btn btn-danger btn-xs glyphicon glyphicon-remove-circle'></button></a></td>";
echo"</tr>";
echo"</table>";
}
}
您必须尝试这样做:
if (mysqli_num_rows($result) > 0) {
echo"<table class='table table-hover table-striped table-responsive'>";
while($row = mysqli_fetch_assoc($result)) {
echo"<tr class='table_row'>";
echo"<td>" . $row['1'] . "</td>";
echo"<td>" . $row['2'] . "</td>";
echo"<td>" . $row['3'] . "</td>";
echo"<td>" . $row['4'] . "</td>";
echo"<td><a href='#'><button type='button' class='btn btn-danger btn-xs glyphicon glyphicon-remove-circle'></button></a></td>";
echo"</tr>";
}
echo"</table>";
}
您正在while循环内重复该表。 希望这对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.