i have a problem on how to save the value of the total score in database
here is my code:
$answer1 = $_POST['q1'];
$answer2 = $_POST['q2'];
$answer3 = $_POST['q3'];
$answer4 = $_POST['q4'];
$answer5 = $_POST['q5'];
$totalCorrect = $_POST['Score'];
$totalCorrect = 0;
if ($answer1 == "B") { $totalCorrect++; }
if ($answer2 == "A") { $totalCorrect++; }
if ($answer3 == "C") { $totalCorrect++; }
if ($answer4 == "D") { $totalCorrect++; }
if ($answer5 == "D") { $totalCorrect++; }
echo "
$totalCorrect / 5 correct";
how can i save the data in $totalcorrect in my database?
can some one help me fix this? Thank you in advance
What I have tried:
i've tried to search online but i cant get the answer.
解决方案answer1 =
_POST['q1'];
answer2 =