Skip to content
Advertisement

Delete MYSQL DB Entry via PHP / HTML Button

Hey.

Iam learning PHP and MYSQL atm.

So i wrote already code which will display everything from my database nicely into HTML. I create also a button which says Delete.

Now i want to write a Code which actually Deletes the specific entry (all have an ID ) but iam kinda lost. i know the command is: $sql = “DELETE FROM cars WHERE car_id=’$car_id'”; but how can i add this event in php to the button click.

I thought in the generating code i add the car id to the button with <button id=”‘.$row[“car_id”.’“> and then somehow magically delete the entry when i click the button but iam stuck & lost in how to call it.

JavaScript

Advertisement

Answer

You can use form with action button name to identify what part of action to do

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement