如何在php中添加删除按钮?

时间:2018-02-14 03:18:32

标签: button sql-delete

i am very new to coding,

我还在学习这些散文,有人可以帮助我如何在此表中为我的编码添加删除按钮, 帮助我:

这是我的代码:

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "registration";

// Create connection
$conn = new mysqli('localhost', 'root', '', 'registration');
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "SELECT id, name, username, age, email, address FROM users ";
$result = $conn->query($sql);

if ($result->num_rows > 0) {

    echo "<table><tr><th>ID</th><th>Name</th><th>Username</th><th>Age</th><th>Email</th><th>Address</th></tr>";
    // output data of each row
    while($row=mysqli_fetch_array($result)){
        echo "<tr><td>" . $row["id"]. "</td><td>" . $row["name"]. " </td><td>" . $row["username"]. " </td><td>" . $row["age"]. " </td>
        <td>" . $row["email"]. " </td><td>" . $row["address"]. " </td><td>"how i want to add delete button here" </td></tr>";       
  }
 echo "</table>";
} else {
    echo "0 results";
}

$conn->close();
?> 

谢谢

1 个答案:

答案 0 :(得分:0)

使用按钮html标记。学习编码时,W3schools是一个很好的资源。以下是按钮标记文档的链接:

https://www.w3schools.com/tags/tag_button.asp