-1
I am making a system of comments, in the form of a list. In each of the lines in the list there is a button of the type <button>
, each with a different name.
And my question is how to make the following syntax of if-lse 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 you click the button, the comment whose "id" matches the name of the button is deleted from the database.
If you can’t do it in PHP, how would it look in Javascript? Remembering that I would have to perform a BD operation.
I tested in the browser and gave that the $ of $('.btn-remove') is not set...
– A. Silva
Friend, what would be this comment_id???
– A. Silva
comment_id is the primary key of the comments entity in your database. About the previous comment, I talked about not just copying and pasting the code, the examples are only for you to base on the idea and not copy and paste to work.
– Kayo Bruno
Ok, actually the cipher error was because it had not imported the jquery library
– A. Silva