如何在 bootstrap table 中添加删除按钮
How to add delete button in a bootstrap table
这些是我用来实现合法table的代码。但是,我似乎无法在名为 "Delete" 的列中添加删除按钮。我真的需要一点帮助。
<tr>
<th>#</th>
<th>Username</th>
<th>Email Address</th>
<th>Last Login</th>
<th>Country</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
if ($result2->num_rows > 0) {
// output data of each row
while ($rows = $result2->fetch_assoc()) {
print "<tr> <td>";
echo $rows['id'];
print "</td> <td>";
echo $rows['user_name'];
print "</td> <td>";
echo $rows['email_address'];
print "</td> <td>";
echo $rows['last_login'];
print "</td> <td>";
echo $rows['country'];
print "</td> <td>";
print "</td> <td>";
要添加一个简单的删除按钮:
while ($rows = $result2->fetch_assoc()) {
...
print "</td> <td>";
print "<a href='delete.php'>Delete</href>
print "</td> <td>";
...
当然,您必须自己创建执行实际删除操作的 delete.php。此外,这还不是一个按钮。但是你可以使用 CSS 使它看起来像一个。
类似的东西:
<?php if ($result2->num_rows > 0) :?>
<?php while ($rows = $result2->fetch_assoc()) :?>
<tr>
<td><?php echo $rows['id']; ?></td>
<td><?php echo $rows['user_name']; ?></td>
<td><?php echo $rows['email_address']; ?></td>
<td><?php echo $rows['last_login']; ?></td>
<td><?php echo $rows['country']; ?></td>
<td><button type="button" class="btn btn-danger">Danger</button></td>
</tr>
<?php endwhile ?>
<?php endif ?>
这些是我用来实现合法table的代码。但是,我似乎无法在名为 "Delete" 的列中添加删除按钮。我真的需要一点帮助。
<tr>
<th>#</th>
<th>Username</th>
<th>Email Address</th>
<th>Last Login</th>
<th>Country</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<?php
if ($result2->num_rows > 0) {
// output data of each row
while ($rows = $result2->fetch_assoc()) {
print "<tr> <td>";
echo $rows['id'];
print "</td> <td>";
echo $rows['user_name'];
print "</td> <td>";
echo $rows['email_address'];
print "</td> <td>";
echo $rows['last_login'];
print "</td> <td>";
echo $rows['country'];
print "</td> <td>";
print "</td> <td>";
要添加一个简单的删除按钮:
while ($rows = $result2->fetch_assoc()) {
...
print "</td> <td>";
print "<a href='delete.php'>Delete</href>
print "</td> <td>";
...
当然,您必须自己创建执行实际删除操作的 delete.php。此外,这还不是一个按钮。但是你可以使用 CSS 使它看起来像一个。
类似的东西:
<?php if ($result2->num_rows > 0) :?>
<?php while ($rows = $result2->fetch_assoc()) :?>
<tr>
<td><?php echo $rows['id']; ?></td>
<td><?php echo $rows['user_name']; ?></td>
<td><?php echo $rows['email_address']; ?></td>
<td><?php echo $rows['last_login']; ?></td>
<td><?php echo $rows['country']; ?></td>
<td><button type="button" class="btn btn-danger">Danger</button></td>
</tr>
<?php endwhile ?>
<?php endif ?>