如何将值插入LainLain
,但仅限于others
列的行Nama
。
这就是我现在在桌子上发生的事情:
Nama | LainLain
value1 | num1
value1 | num1
value1 | num1
value1 | num1
others | num1
我想要实现的目标是什么:
Nama | LainLain
value1 |
value1 |
value1 |
value1 |
others | num1
CODE:
$sign_symptoms = $_POST['sign_symptoms'];
$countSignSymptoms = count($_POST['sign_symptoms']);
for ( $i = 0; $i < $countSignSymptoms; $i++){
if ($sign_symptoms[$i] == "others") {
$other_symptoms == " ";
$pdo->exec("insert into simka_simptom(IDMohon, Nama, LainLain) values ('".$IDMohon."','".$sign_symptoms[$i]."','".$other_symptoms."')");
}
}
任何人都可以帮助我吗?
答案 0 :(得分:0)
试试这个
$sign_symptoms = $_POST['sign_symptoms'];
$countSignSymptoms = count($_POST['sign_symptoms']);
for ( $i = 0; $i < $countSignSymptoms; $i++)
{
if ($sign_symptoms[$i] == "others")
{
$other_symptoms = "num1";
}
else
{
$other_symptoms = "";
}
$pdo->exec("insert into simka_simptom(IDMohon, Nama, LainLain) values
('".$IDMohon."','".$sign_symptoms[$i]."','".$other_symptoms."')");
}