function add_degree($db, $_POST) {
foreach ($_POST['city'] as $cities) {
// Use prepared statements to prevent SQL injection
$sql = $db->prepare("INSERT INTO edu_degrees (`name`, `desc`, `cities`, `unlocks`) VALUES (:name, :desc, :cities, :unlocks)");
$sql->bindParam(':id', $_POST['name'], PDO::PARAM_STR);
$sql->bindParam(':desc', $_POST['desc'], PDO::PARAM_STR);
$sql->bindParam(':cities', $cities, PDO::PARAM_STR); <-- i am not sure about your 'type' here but you can select as you need for validation
$sql->bindParam(':colour', $_POST['unlocks'], PDO::PARAM_STR);
$sql->execute();
}
}
//chk submit before function
if($_POST['submit] === true){
// you can call like this
add_degree($db, $_POST)
}