0, 'Practical' => 0, 'Logical' => 0, 'Reflective' => 0 ]; foreach ($_POST as $key => $value) { $value = (int)$value; if (strpos($key, 'visual_') === 0) { $scores['Visual'] += $value; } if (strpos($key, 'practical_') === 0) { $scores['Practical'] += $value; } if (strpos($key, 'logical_') === 0) { $scores['Logical'] += $value; } if (strpos($key, 'reflective_') === 0) { $scores['Reflective'] += $value; } } arsort($scores); $result = array_key_first($scores); /* SAVE */ $stmt = $pdo->prepare(" INSERT INTO learning_styles (user_id, student_name, roll_number, learning_style) VALUES (?, ?, ?, ?) "); $stmt->execute([ $user_id, $student_name, $roll_number, $result ]); $saved = true; } ?>
Student: = htmlspecialchars($student_name) ?> | Roll: = htmlspecialchars($roll_number) ?>