If the input Idade is different ' ' I need to update my table with the value wich is in the input field valor. Here is my code, plese tell me were I'm wrong.
Code: Select all
<?php
$mysql_id = mysql_connect('localhost', 'curso', '123');
mysql_select_db('vendas',$mysql_id);
/*---actualização da tabela*/
if($_POST['Idade']=''){
$query='update noite set idade=0';
$result=mysql_query($query);
}else{
$query='update noite set idade=$_POST["Valor"]';
$result=mysql_query($query);
}
/*----fim da actualização da tabela*/
$query='Select * from noite';
$result=mysql_query($query);
?>
/*construçao da tabela */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<table border="1">
<?php
while($row=mysql_fetch_array($result)){
?>
<tr>
<td><?php print $row['Nome'];?></td>
<td><?php print $row['Idade'];?></td>
</tr>
<?php
}
?>
</table>
<form action="selecciona.php" method="post">
<p>Idade:<input type="text" name="Idade" value="" label="Idade"/></p>
<p>Valor:<input type="text" name="Valor" value="" /></p>
<p><input type="submit" value="Enviar!" /></p>
</form>
</html>