I want to simultaneously delete images of a specific column ("logo") of a table with another 05 columns, and the destination "upload" of the server.
But I only managed to delete not only the "logo" column but also all the other 05 columns of the DB table, that is, excluding all the row, without excluding the image file referring to the table of the folder (" upload ").
I'm using the script below:
<?php
include 'conexao.php';
$pasta = 'upload/';
if (isset($_POST['deletar'])){
$check = @$_POST['apagar'];
foreach($check as $logo){
$delcheck = mysql_query("DELETE FROM topo WHERE logo = '$logo'") or die (mysql_error());
unlink($pasta.$delcheck['logo']);
if ($delcheck >= '1'){
echo '<script type="text/javascript">
alert("Deletado com sucesso!");
window.location.href = "listar.php";
</script>';
}else{
echo '<script type="text/javascript">
alert("Erro, tente novamente!");
window.location.href = "listar.php";
</script>';
}
}
}
?>
<form action="" method="POST" enctype="multipart/form-data"><br />
<?php
include 'conexao.php';
$seleciona = "SELECT * FROM topo";
$queryum = mysql_query($seleciona);
while ($list = mysql_fetch_array($queryum)){
$logo = $list['logo'];
?>
<input type="checkbox" name="apagar[]" value="<?php echo $logo; ?>" readonly><?php echo $logo; ?><br />
<?php
}
?>
<input type="submit" name="deletar" value="Excluir"><br />
</form>
How can I delete data from a single column of the table, without deleting it completely?
Can anyone tell me if this is possible, and if that's how I should do it?
Thanks in advance.