[英]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.