Как вставить значение в LainLain
, но только для others
строк в столбце Nama
.
Вот что происходит в моем столе прямо сейчас:
Nama | LainLain
value1 | num1
value1 | num1
value1 | num1
value1 | num1
others | num1
Чего я хочу достичь:
Nama | LainLain
value1 |
value1 |
value1 |
value1 |
others | num1
КОД:
$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."')");
}
}
Может кто-нибудь мне помочь?
попробуй это
$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."')");
}