如何从数据库更新记录?
$query = "UPDATE studentinfo SET firstname= '".$student['fname']."' and lastname='".$student['faname']."' and gender = 'Male' WHERE id = '".$student['id']."'";
答案 0 :(得分:2)
UPDATE table SET column1 = 'value1', column2 = 'value2'
不要使用AND来分隔SET子句中的术语。
答案 1 :(得分:1)
$query = "UPDATE studentinfo SET firstname= '".$student['fname']."', lastname='".$student['faname']."', gender = 'Male' WHERE id = '".$student['id']."'";
答案 2 :(得分:1)
AND
在SQL
中用于多个条件。
要更新多个字段,只需用逗号分隔:
$query ="UPDATE studentinfo
SET firstname = '$student['fname']', lastname = '$student['faname']', gender = 'Male'
WHERE id = '$student['id']'";