table 格式错误 bootstrap
Wrong table formatting bootstrap
您好,我在 php 中的这段代码有问题,实际上在 table 中,我想循环从数据库中获取的各种信息,只有当这些信息的长度不同时,格式每个 table 都不好,我希望每行的尺寸都相同,就像我能做的那样?代码工作正常,格式错误......一列比另一列宽。我想在第一行留下单词 "N, name, description" 并以相同的大小循环其余部分。对不起英语
while ($row = mysqli_fetch_array($r_query)) {
echo '
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">N°</th>
<th scope="col">name</th>
<th scope="col">description</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">' . $_id . '</th>
<td>' . $_name . '</td>
<td>' . $_description . '</td>
<td>' . $_lingua . '</td>
<td> <input class="btn btn-primary" type="submit"
value="Send"></td>
</tr>
</tbody>
</table>';
}
尝试将 <table>
部分和 table header 移到 PHP 循环之外,这样循环只会遍历每个数据项并添加一个新 table 行,而不是为每条信息生成一个全新的 table。
echo '<table class="table table-bordered">
<thead>
<tr>
<th scope="col">N°</th>
<th scope="col">name</th>
<th scope="col">description</th>
</tr>
</thead>
<tbody>';
while ($row = mysqli_fetch_array($r_query)) {
echo '<tr>
<th scope="row">' . $_id . '</th>
<td>' . $_name . '</td>
<td>' . $_description . '</td>
<td>' . $_lingua . '</td>
<td><input class="btn btn-primary" type="submit" value="Send"></td>
</tr>';
}
echo '</tbody>
</table>';
您好,我在 php 中的这段代码有问题,实际上在 table 中,我想循环从数据库中获取的各种信息,只有当这些信息的长度不同时,格式每个 table 都不好,我希望每行的尺寸都相同,就像我能做的那样?代码工作正常,格式错误......一列比另一列宽。我想在第一行留下单词 "N, name, description" 并以相同的大小循环其余部分。对不起英语
while ($row = mysqli_fetch_array($r_query)) {
echo '
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">N°</th>
<th scope="col">name</th>
<th scope="col">description</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">' . $_id . '</th>
<td>' . $_name . '</td>
<td>' . $_description . '</td>
<td>' . $_lingua . '</td>
<td> <input class="btn btn-primary" type="submit"
value="Send"></td>
</tr>
</tbody>
</table>';
}
尝试将 <table>
部分和 table header 移到 PHP 循环之外,这样循环只会遍历每个数据项并添加一个新 table 行,而不是为每条信息生成一个全新的 table。
echo '<table class="table table-bordered">
<thead>
<tr>
<th scope="col">N°</th>
<th scope="col">name</th>
<th scope="col">description</th>
</tr>
</thead>
<tbody>';
while ($row = mysqli_fetch_array($r_query)) {
echo '<tr>
<th scope="row">' . $_id . '</th>
<td>' . $_name . '</td>
<td>' . $_description . '</td>
<td>' . $_lingua . '</td>
<td><input class="btn btn-primary" type="submit" value="Send"></td>
</tr>';
}
echo '</tbody>
</table>';