Hi
Thanks for your reply. In fact I was using UPDATE but even changing that it doesn't work and what I need is to update a contact based on the user id like explained and corrected bellow. The correct full scriptthat I made is:
http://www.mysite.com/act.php?id=5
where I wanted to update the data for the user with the id=5
Any help here would be great, the code details are bellow…
Thanks in advance
Mario Pro
The table structure
| id | nome | apelido | telefone | telemovel | fax | email | web |
| | | | | | | | |
// The update form file named "act.php"
<?
$username="user";
$password='';
$database="xpto";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM contact WHERE id='$id'";
$result=mysql_query($query);
$num = mysql_num_rows($result);
mysql_close();
$i=0;
while ($i < $num) {
$nome=mysql_result($result,$i,"nome");
$apelido=mysql_result($result,$i,"apelido");
$telefone=mysql_result($result,$i,"telefone");
$telemovel=mysql_result($result,$i,"telemovel");
$fax=mysql_result($result,$i,"fax");
$email=mysql_result($result,$i,"email");
$web=mysql_result($result,$i,"web");
?>
<form action="actualiza.php">
<input type="hidden" name="ud_id" value="<? echo "$id"; ?>">
Nome: <input type="text" value="ud_nome" value="<? echo "$nome"; ?>"><br>
Apelido: <input type="text" name="ud_apelido" value="<? echo "$apelido"; ?>"><br>
Telefone: <input type="text" name="ud_telefone" value="<? echo "$telefone"; ?>"><br>
Telemóvel: <input type="text" name="ud_telemovel" value="<? echo "$telemovel"; ?>"><br>
Fax: <input type="text" name="ud_fax" value="<? echo "$fax"; ?>"><br>
E-mail: <input type="text" name="ud_email" value="<? echo "$email"; ?>"><br>
Web: <input type="text" name="ud_web" value="<? echo "$web"; ?>"><br>
<input type="Submit" value="Update">
</form>
<?
++$i;
}
?>
// The update php file named "actualiza.php"
<?
$username="user";
$password='';
$database="xpto";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="UPDATE contact WHERE id='$ud_id' contact SET nome='$ud_nome' apelido='$ud_apelido' telefone='$ud_telefone' telemovel='$ud_telemovel' fax='$ud_fax' email='$ud_email' web='$ud_web'";
mysql_query($query);
echo "Registo actualizado";
mysql_close();
?>