Im trying to get my query to update upon user click This one here works but it doesnt wanna update I Says Query Empty
I edited the code as follows
if ($action == "edit"){
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$result=mysql_query("UPDATE user SET first_name='$first_name',last_name='$last_name',email='$email' WHERE id=$id");
$sql = mysql_query($result) or die (mysql_error());
}
$sql=mysql_query("select * from user where id='$id'");
while ($row=mysql_fetch_array($sql)){
$id = $row['id'];
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$email = $row['email'];
echo("<form name='edit' method='post' action='?action=edit'>");
echo("<input type='hidden' name='?action=edit'>");
echo("<table class=main cellspacing=0 cellpadding=5 >");
echo("<tr><td>Name: </td><td align='right'><input type='text' name='first_name' value='$first_name'></td></tr>");
echo("<tr><td>Surname: </td><td align='right'><input type='text' name='last_name' value='$last_name'></td></tr>");
echo("<tr><td>Email: </td><td align='right'><input type='text' name='email' value='$email'></td></tr>");
echo("<tr><td></td><td><div align='right'><input type='submit'></div></td></tr>");
echo("</table>");
}
}
echo("<br>");
echo("</form>");
I added $sql = mysql_query($result) or die (mysql_error());
the above line shows what time of error the query encounted while executing... Any Ideas as to why the query is empty and wheres there is data in the table?
This Code will run upon the clicking of this link
echo"<a href='test.php?action=edit&id=$id'>Edit</a>";