English 中文(简体)
如何从数据库中删除表格浏览量?
原标题:How can i delete table row from database?

清单.js 档案

删除一行:

td = document.createElement("td");          
          td.setAttribute("style","border: 1px solid black;");          
          cellText = document.createElement( i ); 
          cellText.setAttribute("data-id",data[i].pid);         
          cellText.setAttribute("class","fa-solid fa-trash");
          cellText.setAttribute("onclick", "pDelete(this)");
          td.appendChild(cellText);          
          row.appendChild(td);     

pDelete(elem):

pDelete(elem) {
        let id = elem.getAttribute("data-id");
        fetch(`pdelete/index.php?id=${id}`, {
            method:  DELETE 
        });
    }

页: 1 工作档案:

public static function pDelete($params){
        $params=json_encode($params, true);
        extract(json_encode($params,true));
        $db=new DBConnect();
        $sql="DELETE from products  WHERE pid=:$id";
        $db->sqlExec($sql);
    }

pdelete/index.php file:

<?php

require_once("../app/pWorks.php");

if ($_SERVER["REQUEST_METHOD"] == "DELETE") {
    $id = isset($_GET[ id ]) ? $_GET[ id ] : null;
    if (!empty($id)) {
        pWorks::pDelete($id);
        echo "deleted";
    }else{echo "nope";}

}

我的首要任务是在数据库上 p。 它有意删除任何内容。

我的首要任务是在数据库上 p。 它有意删除任何内容。 我的首要任务是在数据库上 p。 它有意删除任何内容。 我的首要任务是在数据库上 p。 它有意删除任何内容。 我的首要任务是在数据库上 p。 它有意删除任何内容。 我的首要任务是在数据库上 p。 它有意删除任何内容。 我的首要任务是在数据库上 p。 它有意删除任何内容。 我的首要任务是在数据库上 p。 它有意删除任何内容。 我的首要任务是在数据库上 p。 它有意删除任何内容。 我的首要任务是在数据库上 p。 它有意删除任何内容。 我的首要任务是在数据库上 p。 它有意删除任何内容。

问题回答

载于<代码>p 页: 1 此外,没有必要重新编号参数,因为这些参数已经作为初等人物通过。 因此,你应当改写“JSON”号:

public static function pDelete($params){
    $params = json_decode($params, true);
    $id = $params[ id ];
    $db = new DBConnect();
    $sql = "DELETE FROM products WHERE pid=:id";
    $db->sqlExec($sql, [ id  => $id]); 
}

请检查答复状况并处理:

pDelete(elem) {
    let id = elem.getAttribute("data-id");
    fetch(`pdelete/index.php?id=${id}`, {
        method:  DELETE 
    })
    .then(response => {
        if (response.ok) {
            console.log("Deleted successfully");
            // you can remove the row from the table if deletion was successful
        } else {
            console.error("Failed to delete:", response.statusText);
        }
    })
    .catch(error => {
        console.error("Error:", error);
    });
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签