-1
I want to simultaneously delete images from a specific column ("logo") of a table with more than 05 columns, and from the server’s target folder ("upload").
But I was only able to delete not only the column ("logo") but all the other 05 columns of the BD table, that is, excluding the entire row, without deleting the image file referring to the folder table ("upload") of destination.
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>
It has as I delete data from a single column of the table, without deleting it completely?
Could someone please let me know if this is possible, and if this is how I should do it?
From now on my thanks.
Since you do not want to delete the row but only values that are in the column vc does an update table set logo="" Where logo="name_a_ser_excluded". So all lines that have this value you want to exclude are empty.
– Thalles Daniel