Skip to content

Instantly share code, notes, and snippets.

@TiuTalk
Created February 20, 2015 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TiuTalk/e70694811e0ab64899f6 to your computer and use it in GitHub Desktop.
Save TiuTalk/e70694811e0ab64899f6 to your computer and use it in GitHub Desktop.
<?php
// Inclui o arquivo que faz a conexão ao MySQL
include("conexao.php");
// Montamos a consulta SQL para deletar notícias que não sejam desse ano
$query = "DELETE FROM `noticias` WHERE (`cadastro` < '2009-01-01 00:00:00') OR (`cadastro` > '2009-12-31 23:23:59')";
// Executa a query
$deletar = mysql_query($query);
if ($deletar) {
echo "As notícias de outros anos foram deletadas com sucesso!";
} else {
echo "Não foi possível deletar as notícia, tente novamente.";
// Exibe dados sobre o erro:
echo "Dados sobre o erro:" . mysql_error();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment