Olá pessoal.. Sou novo por aqui e nenêm em PHP..., gostaria que algue pudesse me ajudar, pois já fui em uma porrada de fórum não obtive sucesso.... então vamos ao desafio.... imagine uma tabela de alunos com um id, nome e campo para edição de sua nota... nesta tabela, os alunos serão exibidos conforme busca no banco de dados..., e para cada aluno deverá ter um campo para a inserção de sua nota... montar a página foi facil... o problema é que não consigo fazer o update das notas no bd... Ex da tabela: ID---------ALUNO---------NOTA------ 01---------JOSE-----------|10,1|-------- 02---------JOAO ----------|09,3|-------- 03---------MARIA ---------|03,5|------- A nota esta em um campo de formulário..., os alunos aparecem de acordo com uma consulta no bd.. se na minha tabela do bd tem 3 colunas... ID..,NOME..e NOTA..., como eu faço para alterar as notas já existentes na coluna NOTA??? lá vai meu código p ver se ajuda em algo.... CREATE TABLE alunos ( IDALUNO tinyint(4) NOT NULL default '0', DESCRI varchar(50) default NULL, NOTA varchar(4) NOT NULL default '' ) ENGINE=InnoDB DEFAULT CHARSET=latin1; # # Dumping data for table 'alunos' # INSERT INTO alunos VALUES("1", "JOAO", "4"); INSERT INTO alunos VALUES("2", "MARIA", "4"); INSERT INTO alunos VALUES("3", "JOSE", "4"); INSERT INTO alunos VALUES("4", "PEDRO", "4"); # # Table structure for table 'professores' # CREATE TABLE professores ( ID_EMITENTE tinyint(3) NOT NULL auto_increment, NOME varchar(50) default NULL, RAZAO varchar(50) default NULL, PRIORIDADE tinyint(3) NOT NULL default '0', LOGIN varchar(7) NOT NULL default '', SENHA varchar(7) NOT NULL default '', PRIMARY KEY (ID_EMITENTE), UNIQUE KEY NOME_RAZAO_UNICOS (RAZAO,NOME) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; # # Dumping data for table 'professores' # INSERT INTO professores VALUES("4", "3", "3", "0", "3", "3"); INSERT INTO professores VALUES("9", "2", "2", "0", "2", "2"); ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ PAGINA INICIAL (INDEX) <html> <php ?> <head> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>Nova pagina 1</title> </head> <body bgcolor="#FFFFFF"> <p align="center"> </p> <p align="center"> </p> <p align="center"> <span style="font-weight: 700; font-style: italic; "> <font size="5" color="#0033CC">CONTROLE DE NOTAS </font></span></p> <p align="center"> </p> <p align="center"> <a href="alterar_notas.php">altere aqui as notas </a><br><font color="#C0C0C0"><br> </font></p> </body> </html> ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ PAGINA DE ALTERAÇÕES: <html> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="45" bgcolor="#008000"> <tr> <td width="100%" height="45"> <p align="center"><i><font size="5" color="#FFFFFF" face="Arial">CONTROLE DE NOTAS</font></i></td> </tr> </table> <br> <?php $host = "localhost"; $user = ""; $pass = ""; $db = "notas"; $socket = mysql_connect($host,$user,$pass) or die(mysql_error()); $res = mysql_db_query('bd_notas',"SELECT * FROM alunos", $socket); $numero = mysql_num_rows($res); echo "Existem $numero alunos nesta turma! <br>"; echo '<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%"> <tr> <th bgcolor= "#008000" ><font color="#FFFFFF" size="2"><b><i>CODIGO ALUNO</i></b></font></th> <th bgcolor= "#008000" ><font color="#FFFFFF" size="2"><b><i>ALUNO</i></b></font></th> <th bgcolor= "#008000" ><font color="#FFFFFF" size="2"><b><i>NOTA</i></b></font></th> </tr>'; while ($valor=mysql_fetch_array($res)) echo "<tr> <td >$valor[iDALUNO]</td> <td >$valor[DESCRI]</td> <td ><form method='post' action='altera_db_notas.3.php?CAD_IDNOTA=1'> <input type='text' name='VALOR' size='10' style='font-size: 7 pt'><font size='2'> </td> </tr>"; echo "</table>"; ?> <!-- ---------------------------------------------------------------------------------------------------------- --> <input type="reset" value="Limpar" name="limpar"> <input type="submit" value="Salvar" name="salvar"> </p> </form> <!-- ---------------------------------------------------------------------------------------------------------- --> <!--<a href="index.php">Voltar ao inicio</a>--> </html> ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ PAGINA DE ATUALIZAÇÃO DO BD: <?php $servidor = 'localhost'; $usuario_db = ''; $senha_db = ''; $banco = 'bd_notas'; $con = mysql_connect($servidor, $usuario_db, $senha_db); mysql_select_db($banco); $sql="UPDATE alunos SET NOTA='$_POST[VALOR]' "; $resultado=mysql_query($sql) or die("não foi possivel realizar a ALTERAÇÃO dos dados"); echo("As alterações foram realizadas com sucesso !!!"); echo "<br> <p align='center'><font color='#808080'> </font><a href='index.php'><font color='#808080'> Voltar ao inicio </font> "; echo "<br>"; ?> -------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------- Bem ai esta... espero que possa ajdar a entender minha duvida...