5
I’m making a simple PHP code to delete database email, only I need to use one if
and else
if a given action occurs.
If for example, deleting an email shows a particular message, or if you do not have that email requested in the database, a message appears that this data is no longer present in the table follows the code.
<?php
$emailDel = $_POST['delemail'];
$dbc = mysqli_connect('localhost', 'xavier', 'xavier', 'store_database')or die('não foi possivel acessar Banco de Dados');
$query = "DELETE FROM clients WHERE email = '$emailDel'";
$result = mysqli_query($dbc, $query)or die('não foi possivel acessar Banco de Dados');
if($result = TRUE){
echo $emailDel.' as deleting from database';
}else{
echo $emailDel.' it is not present in database';
}
mysqli_close($dbc);
?>
Missed fetch_assoc, without it you do not take the result of the query
– rray
This is wrong
if($result = TRUE){
right isif($result == TRUE){
orif($result === TRUE){
or justif($result){
.– Guilherme Nascimento
@rray I think this is not necessary because it is not a consultation but a
DELETE from
?– Guilherme Nascimento
What’s the matter?
– rray
I found the problem quite clear.. I did not understand why they voted negative or to close.
– Daniel Omine
@rray because the consultations of the type
DELETE
,UPDATE
,INSERT
returnTRUE
orFALSE
only.– Edilson
@Edilson, there was no code before in the question, I figured I was doing a select before delete.
– rray
@rray Yes, I just saw that the question was edited.
– Edilson