Ir para conteúdo
Fórum Script Brasil
  • 0

Excluir Dados No Mysql E Arquivos Juntos


ronkenoli

Pergunta

Ola galera, mais uma vez venho até vocês pedir ajuda, não estou conseguindo excluir dados do Mysql, e junto um arquivo anexado, já fiz um Script, mais não está excluindo, e não sei como fazer o php excluir o anexo, vou mostra a vocês como esta;

code:

<?

error_reporting (E_ALL);

ini_set ("display_errors", 1);

session_start("admin");

if($_SESSION["adm_log"]!="){

include("../conecta_bd.php") ;

if($REQUEST_METHOD == "POST"){

$acao=$_GET["acao];

$id_adm=$_GET["id_curriculo"];

if($acao == "excluir"){

$sql="DELETE FROM 'ac_curriculos' WHERE 'ac_curriculos'.'id_curriculo' = '$id_curriculo'";

executa($id,$sql);

echo "<script>alert('Administrador excluído com êxito')</script>";

}

}

$query = "SELECT * FROM ac_curriculos";

$result = executa($id,$query) ;

?>

<head>

<title></title>

<link href="../style/style.css" rel="stylesheet" type="text/css">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="JavaScript">

function excluir(Candidato){

if(confirm('Tem certeza que deseja excluir o Candidato?')){

window.location = 'candidatos.php?acao=excluir&id_curriculo='+Candidato ;

}

}

</script>

<style type="text/css">

<!--

.style1 {

color: #FF9900;

font-weight: bold;

}

.link {

font-family: Arial, Helvetica, sans-serif;

font-size: 12px;

font-weight: normal;

text-decoration: none;

color: #000000;

}

-->

</style>

</head>

<body leftmargin="0" topmargin="18" marginwidth="0" marginheight="0">

<table width="574" height="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">

<tr>

<td height="58">

<img src="imagens/candidato.gif" width="574" height="56"></td>

</tr>

<tr>

<td height="132">

<center>

<table width="550" border="0" cellspacing="0" cellpadding="0">

<tr>

<td><table width="550" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" >

<tr>

<? while($row = mysql_fetch_array($result)){extract($row) ; ?>

<td width="110" bordercolor="#CCCCCC"> Candidato:</td>

<td width="440" bordercolor="#CCCCCC"> <?= $nome ?></td>

</tr>

<tr>

<td height="19"> Telefone:</td>

<td height="19"> <?= $tel ?></td>

</tr>

<tr>

<td height="19"> Currículo:</td>

<td height="19"> <a href="../curriculos/<?= $arquivo ?>" target="_blank"><?= $arquivo ?></a></td>

</tr>

<tr>

<td height="19"> Data de envio: </td>

<td height="19"> <?= $data ?></td>

</tr>

<tr>

<td height="19" style="border-bottom-width:2px;

border-bottom-color:#FF9900;

border-bottom-style:solid;">

Ação

</td>

<td height="19" style="border-bottom-width:2px;

border-bottom-color:#FF9900;

border-bottom-style:solid;"><a href="java script:void(excluir(<?= $id_curriculo ?>))" class="link"> [exclui]</a></td>

</tr>

<? } ?>

</table></td>

</tr>

<tr>

<td height="19"> </td>

</tr>

</table>

<table width="550" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

<td> </td>

</tr>

</table>

</center>

</td>

</tr>

</table>

</body>

<?

}

else

{

echo "<script>window.open('index.php','_top')</script>";

}

?>

Na linha 75:

<a href="../curriculos/<?= $arquivo ?>" target="_blank"><?= $arquivo ?></a>

E onde esta o anexo.

Bom desde já fico muito grato.

Atenciosamente, Marcelo Rogério.

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

Olha, verifica se ele tá excluindo do banco pelo menos.

se não tiver, muda essa consulta

DELETE FROM 'ac_curriculos' WHERE 'ac_curriculos'.'id_curriculo' = '$id_curriculo'
pra isso
DELETE FROM ac_curriculos WHERE id_curriculo = '".$id_curriculo."'

Talvez essas aspas estejam atrapalhando

Esse 'anexo' que você está tratando é um arquivo no diretorio né?! Uma imagem que subiu na hora do cadastro ou outra coisa parecida. É isso?

P se for você vai ter que usar unlink para deletar o arquivo

tipo:

$arquivo = "pasta/pasta/arquivo.ext";

unlik($arquivo);

+/- isso

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,8k
×
×
  • Criar Novo...