douni1396
douni1396
2019-04-21 17:02

如何使按钮修改数据库中的数据

  • php
  • html

I have a page which connects to the database and gets some data including title and content.
I use a while loop to echo the data inside this page, what I'm trying to do is to have 2 buttons under every result that comes from database which is the "Edit" and "Delete" buttons. The problem is I don't know how to make buttons remove or edit the right column.
EDIT
Added the PHP part:

$sql = "SELECT * FROM posts ORDER BY date DESC, time DESC $limit";
$query = mysqli_query($conn, $sql);
<?php
while ($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
    ?>
    <section>
        <b>Title: </b>
        <p><?php echo $row['name'] ?></p><br>
        <b>Content: </b><br>
        <p><?php echo $row['content'] ?></p><br>
//want to have two buttons here which can be used to edit or delete the colunm that they are under it
    </section>
    <?php
}
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答