我试图根据用户操作更新表格,请帮忙,当我提交查询时,如果用户选择编辑它应该更新表格我做错了什么?
if ($action == "edit"){
$edit = $_POST['edit'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$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'];
$result=mysql_query("UPDATE user SET first_name='$first_name',last_name='$last_name',email='$email' WHERE id='$id'");
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>");
}
}