Ir para conteúdo
Fórum Script Brasil

evertonlima

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Tudo que evertonlima postou

  1. evertonlima

    Ajuda Mysql PHP

    Pessoal estou com uma dificuldade em resolver um problema de edição no mysql usando php, tenho as telas abaixo que ao editar não visualiza mais o e-mail. O sistema cadastra e exclui normalmente. Também não consegui colocar as páginas php em utf-8. Agradeço a ajuda. bd CREATE TABLE IF NOT EXISTS `aniversarios` ( `id` int(11) NOT NULL AUTO_INCREMENT, `nome` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `email` longtext COLLATE utf8_unicode_ci NOT NULL, `dataniver` date NOT NULL, PRIMARY KEY (`id`), KEY `id` (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; tela listar.php tela após editar da listar.php código listar.php <a href="index.html">Voltar</a> | <a href="cadastro.php">Novo Cadastro</a> <?php include 'conn.php'; $re = mysql_query("SELECT * FROM aniversarios ORDER BY id;"); ?> <br /> <table width="100%" border="1"> <tr> <td><b>Acoes</b></td> <td><b>Nome</b></td> <td><b>Email</b></td> <td><b>Data Aniversário</b></td> </tr> <?php while($l = mysql_fetch_array($re)) { $id = $l["id"]; $nome = $l["nome"]; $email = $l["email"]; $dataniver = $l["dataniver"]; $data = implode("/",array_reverse(explode("-",$dataniver))); echo " <tr> <td><a href=\"editar.php?id=$id\">[Editar]</a> <a href=\"excluir.php?id=$id\">[Excluir]</a></td> <td> $nome</td> <td> $email</td> <td> $data</td> </tr>\n"; } @mysql_close(); ?> </table> código editar.php <?php include 'conn.php'; // Recuperando ID do cliente $id = $_GET['id']; // Verificando ação a ser executada $acao = $_GET['acao']; if($acao == "editar") { $nome = $_POST["nome"]; $email = $_POST["email"]; $dataniver = $_POST['dataniver']; $data = implode("-",array_reverse(explode("/",$dataniver))); $sql = mysql_query("UPDATE aniversarios SET nome='$nome',email='$email',dataniver='$data' WHERE id='$id'"); if ($sql){ echo "<script language='javascript'>alert('Cliente editado com sucesso'); window.location.href = 'listar.php'</script>"; } else { echo "<script language='javascript'>alert('Não foi possível editar o cliente'); window.location.href = 'listar.php'</script>"; } } $order = "SELECT * FROM aniversarios where id='$id'"; $result = mysql_query($order); $row = mysql_fetch_array($result); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Editar</title> <style> <!-- .textBox { border:1px solid gray; width:200px;} --> </style> </head> <body> <form method="post" action="editar.php?id=<?php echo $id ?>&acao=editar"> <table width="400" border="0" align="center"> <tr> <td width="145">Nome</td> <td width="245"><input name="nome" type="text" id="nome" maxlength="100" class="textBox" value="<? echo "$row[nome]"?>" /></td> </tr> <tr> <td>Email</td> <td><input name="email" type="text" id="email" maxlength="100" class="textBox" value="<? echo "$row[email]"?>" /></td> </tr> <tr> <td>Data Nascimento</td> <td><input name="email" type="text" id="data" maxlength="10" class="textBox" value="<? echo date("d/m/Y", strtotime($row[dataniver]));?>" /></td> </tr> <td> <input type="submit" name="submit" value="Editar"> </table> </form> <a href="listar.php">Voltar</a> </body> </html>
×
×
  • Criar Novo...