嗨,你可以幫我做我的查詢更新如果表如果id存在然後如果不插入它? 這裏是我的查詢:插入id是否存在,或者如果id存在查詢則更新表?
if(isset($_POST['submit'])){
$a=$_POST['no1']; $b=$_POST['ans1']; $c=$_POST['det1'];
$d=$_POST['no2']; $e=$_POST['ans2']; $f=$_POST['det2'];
$g=$_POST['no3']; $h=$_POST['ans3']; $i=$_POST['det3'];
$j=$_POST['no4']; $k=$_POST['ans4']; $l=$_POST['det4'];
$m=$_POST['no5']; $n=$_POST['ans5']; $o=$_POST['det5'];
$p=$_POST['no6']; $q=$_POST['ans6']; $r=$_POST['det6'];
$s=$_POST['no7']; $t=$_POST['ans7']; $u=$_POST['det7'];
$v=$_POST['no8']; $w=$_POST['ans8']; $x=$_POST['det8'];
$y=$_POST['no9']; z=$_POST['ans9']; $zz=$_POST['det9'];
$aa=$_POST['no10']; $bb=$_POST['ans10']; $cc=$_POST['det10'];
$sql=mysql_query("insert into bfp_personnel_questions `(`id`,`question_number`,`answer`,`details`) VALUES ('$id', '$a', '$b','$c'), ('$id','$d','$e','$f'), ('$id','$g','$h','$i'), ('$id','$j','$k','$l'), ('$id','$m','$n','$o'), ('$id','$p','$q','$r'), ('$id','$s','$t','$u'), ('$id','$v','$w','$x'), ('$id','$y','$z','$zz'), ('$id','$aa','$bb','$cc')") or die(mysql_error());`
?><script>alert("Successfully Saved.");window.location="pds_1st.php?part=11";</script><?php }
}
[Duplicate](http://stackoverflow.com/questions/6030071/mysql-table-insert-if-not-exist-otherwise-update)。 – ccKep
可能重複[如何在MySQL中插入'如果不存在'](http://stackoverflow.com/questions/1361340/how-to-insert-if-not-exists-in-mysql) – ccKep