How to delete a row from a SQL table?

前端 未结 1 1413
后悔当初
后悔当初 2021-01-13 13:53

I have a row that needs to be deleted from a SQL table via PHP. The table has 3 columns: id, Symbol, and Shares:

foreach ($rows as $row)
{
    if($row[\"Symb         


        
相关标签:
1条回答
  • 2021-01-13 14:12

    This syntax should work in any database:

    DELETE FROM stocks WHERE id = XXX
    

    I don't know what ? $_SESSION[id] is supposed to be doing. Try without the ?:

    DELETE FROM stocks WHERE id = $_SESSION[id]
    

    That said, you should parameterize your queries rather than putting arguments into the query string.

    0 讨论(0)
提交回复
热议问题