I'm doing a comment system, in list form. In each of the lines of the list there is a button of type <button>
, each with a different name.
And my question is how to do the following if-else syntax in PHP:
If (o "< button >< /button >" de nome $idcomentario for clicado){***
$comando = $PDO->prepare("DELETE comentario FROM comentarios WHERE
idcomentario = :idcomentario");
$comando->bindValue(':idcomentario', $idcomentario);
$comando->execute();
}else{
//nada acontece...
}
That is, when the button is clicked, the comment whose "id" corresponds to the button name is deleted from the database.
If you can not do it in PHP, how would you look at JavaScript? Remembering that I would have to perform a BD operation.