Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Bom pessoal sou leigo em PHP e mysql, hoje decidi fazer o que aprendi lendo, que seria gravar... inserir... editar.. e deletar
A parte se inserir foi tudo certo, agorra estou fazendo a parte de edição, só que não apresenta erro algum e tbm não grava mysql
Codigo que está enviando as informações para edição é :
<?
include "config.php";
?>
<!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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>if (isset ($_GET['fazer']) == "editar")
$id = $_GET['id'];
$sql_update = mysql_query("SELECT * FROM alunos WHERE id = '$id'"); $nome = $linha['nome'];
$turno = $linha['turno'];
}
?>
<form id="form2" name="form2" method="post" action="actioneditar.php">
<table width="150" border="0" cellspacing="3">
<tr>
<td colspan="2">Tabela de Edição</td>
</tr>
<tr>
<td>Nome:</td>
<td><label>
<input type="text" name="nome" id="nome" value="<? echo $nome ?>" />
</label> </td>
</tr>
<tr>
<td>Turno:</td>
<td><label>
<input type="text" name="turno" id="turno" value="<? echo $turno ?>" />
</label></td>
</tr>
</table>
<label>
<input type="submit" name="button" id="button" value="Editar" />
</label>
</form>
</body>
</html>
e o que faz a parte de verificar e alterar no mysql e depois mostrar a tabela alterada é o seguinte codigo
<?
include "config.php";
$grava_nome = $_POST['nome'];
$grava_turno = $_POST['turno'];
if(!isset($_GET['funcao']) == "editar")
{
$id = $_GET['id'];
$sql_alterar = mysql_query("UPDATE alunos SET nome='$grava_nome', turno='$grava_turno' WHERE id = '$id'");
header('Location:visualizar.php');
}
?>
Se for possivel alguem me indicar algum curso de PHP e mysql online que ja tenha visto e axado muito bom ou algum livro, :D estou disposto a aprender hehe
Abraço a todo pessoal do Imaster
Carregando comentários...