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

Sempre pega a primeira ID


black power

Pergunta

Boa tarde, pessoal estou com dificuldades de fazer funcionar este script de remover evento.

Ele sempre está pegando a ID_Evento = 1;

Não o ID_Evento escolhido por min.

Aonde estou errando.

Obrigado

<fieldset>
    <legend class="tahoma11black"><strong>Eventos Cadastrados </strong></legend>
    <br />
    <?php 
     
     $SQL = "SELECT * from table_usuario_sistema order BY ID_Usuario";
     $ret = mysql_query($SQL,$link)or die(mysql_error());
     while($row = mysql_fetch_array($ret)){
       $ID_Usuario = $row['ID_Usuario'];
     $NomeGerente = $row['NomeGerente'];
        
      //echo" $NomeGerente<br>";
     }
    
    
    ?>
    
      <?php 
        echo"<table width=\"720\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\" align=\"center\">
        <tr>
        <td width=\"68\" height=\"20\" bgcolor=\"#333333\"><div align=\"center\" class=\"tahoma11blank\"><strong>Ação</strong></div>        </td>
        <td width=\"238\" height=\"20\" bgcolor=\"#333333\"><div align=\"center\" class=\"tahoma11blank\"><strong>Nome do Evento        </strong></div></td>
        <td width=\"252\" height=\"20\" bgcolor=\"#333333\"><div align=\"center\" class=\"tahoma11blank\"><strong>Descrição Evento        </strong></div></td>
        <td width=\"149\" height=\"20\" bgcolor=\"#333333\"><div align=\"center\" class=\"tahoma11blank\"><strong>Gerente Responsável        </strong></div></td>
        </tr>";
  
     $SQL3 = "SELECT * from table_cadastro_evento order BY ID_Evento DESC";
     $ret3 = mysql_query($SQL3,$link)or die(mysql_error());     
     while($row3 = mysql_fetch_array($ret3)){
       $ID_Evento = $row3['ID_Evento'];
     $NomeEvento = $row3['NomeEvento']; 
     $ID_Cliente = $row3['ID_Cliente'];
     $DescricaoEvento = $row3['DescricaoEvento'];    
     $ID_AdministradorEvento = $row3['ID_AdministradorEvento'];
          
     if ($corAtual == "#E8F3FF") {
     $corAtual = "#E4E4E4";
     } else {
       $corAtual = "#E8F3FF";
     }
     
  echo"
  <tr height=\"20\" bgcolor=\"$corAtual\" align=\"center\">
    <td><table width=\"57\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td width=\"33\" align=\"center\">";
    echo"
    <a href=\"dadosEvento.php?ok=1&ID_Evento=$ID_Evento\">";
    
    echo"
    <img src=\"img/ico_editar.gif\" alt=\"Editar Evento\" width=\"20\" height=\"20\" border=\"0\" /></a></td>
    <td width=\"24\" align=\"left\"><a href=\"#\" onClick=\"apagar($ID_Evento)\"><img src=\"img/ico_deletar.gif\" alt=\"Deletar Evento\" border=\"0\" /></a></td>
  </tr>
</table>
</td>
    <td align=\"center\"><div class=\"tahoma11black\">";echo SubStrInt($NomeEvento, 32, false) . '...';  echo"</div></td>
    <td align=\"center\"><div class=\"tahoma11black\">$DescricaoEvento</div></td>
    <td align=\"center\"><div class=\"tahoma11black\">$ID_AdministradorEvento - Substituir Pelo Nome</div></td>
  </tr>";
  

 }
    echo"</table>";
    
    ?>

<br /><br />
    </fieldset>

    &lt;script language="JavaScript">
function apagar(id) {
if (window.confirm('<?php echo $ID_Evento; ?>Deseja apagar este registro?\não efetuar a exclusão: Automaticamente os registros filhos deste evento será removido!')) {
 window.location.href = 'deletarEvento.php?ok=1&ID_Evento=<?php echo $ID_Evento; ?>'
}
else { window.alert('Ok, nenhuma ação foi feita!') }
}
</script>

Link para o comentário
Compartilhar em outros sites

3 respostass a esta questão

Posts Recomendados

  • 0

bom não conheço muito...ainda estou só aprendendo também...mas será que não é porque a variavel que vai receber o ID está depois do select?? porque assim acredito que o php siga uma ordem, e nesse caso ele está fazendo o select primeiro e recebendo a variavel depois...se eu estiver errado, por favor...alguém me diga....

mas tenta isso...

Link para o comentário
Compartilhar em outros sites

  • 0

Seguinte... Teu erro é de Javascript e não PHP.

Olha o que tu fizeste:

function apagar(id) {
if (window.confirm('<?php echo $ID_Evento; ?>Deseja apagar este registro?\não efetuar a exclusão: Automaticamente os registros filhos deste evento será removido!')) {
window.location.href = 'deletarEvento.php?ok=1&ID_Evento=<?php echo $ID_Evento; ?>'
}
else { window.alert('Ok, nenhuma ação foi feita!') }
}
Obviamente, ele vai pegar o valor de $_ID_Evento e ecoar dentro do Javascript! O certo é:
function apagar(id) {
        if(window.confirm(id+': Deseja apagar este registro?'))
            window.location.href = 'deletarEvento.php?ok=1&ID_Evento='+id;
        else { window.alert('Ok, nenhuma ação foi feita!') }
        }

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...