无法将id传递给url

时间:2018-04-27 15:36:28

标签: php pdo

我有以下按钮,应删除已选择的项目

$content .= "<td> " . "<a href=/index.php?p=3&id=$id>delete</a>";

然而,这总是让我:

http://localhost/index.php?p=3&id=

当p = 3时,它应该调用以下函数:

case 3:
$items = new dbconnection();
$content = $items->deleteItem($_GET['id']);

/

public $id;
public function deleteItems($id) {
    $conn = dbconnection::startconnection();

    $this->id = $id;

    $sql = "DELETE FROM items where id = '$this->id'";
    $stmt = $conn->prepare($sql);
    $stmt->execute();

    $content ="<p>" . "<a href=index.php>Go back</a>" . "</p>";

    return $content;
}
public function __construct($id = 1) {

}

为什么ID没有发送到URL?

0 个答案:

没有答案
相关问题