$answers = ambilJawabanUSER($simpanID,$conn); // function to save the answer from database table
$userAnswer = $_POST['answers'];
foreach( $userAnswer as $getAnswer ) {
if ($userAnswer == $answers){
echo "correct";
else{
echo "wrong";
}
}
my code is similar with the code above but it didnt work in my case. anyone has the solution?
I think you have one error in code. Your should try this code
$answers = ambilJawabanUSER($simpanID,$conn); // function to save the answer from database table
$userAnswer = $_POST['answers'];
foreach( $answers as $getAnswer ) {
if ($userAnswer == $getAnswer){
echo "correct";
}else{
echo "wrong";
}
}