【问题标题】:How to add delete button in a bootstrap table如何在引导表中添加删除按钮
【发布时间】:2015-06-10 05:20:53
【问题描述】:

这些是我用来实现合法表的代码。但是,我似乎无法在名为“删除”的列中添加删除按钮。我真的可以在这里得到一点帮助。

  <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>";

【问题讨论】:

  • 您要删除什么?表格行或数据库中的数据?
  • 如果您喜欢这些答案,您应该通过单击绿色勾号来选择一个。这标志着 StackOverflow 中解决的问题。

标签: php twitter-bootstrap button


【解决方案1】:

类似的东西:

<?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 ?>

【讨论】:

    【解决方案2】:

    添加一个简单的删除按钮:

    while ($rows = $result2->fetch_assoc()) {
        ...
        print "</td> <td>";
        print "<a href='delete.php'>Delete</href>
        print "</td> <td>";
        ...
    

    当然,您必须自己创建执行实际删除操作的 delete.php。此外,这还不是一个按钮。但是你可以使用 CSS 让它看起来像一个。

    【讨论】:

    • 完美!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多