how to update multiple select box values in php mysql

<select name="specialization" multiple>
            <option value=""></option>
            <option value="United States" selected>United States</option>
            <option value="United Kingdom">United Kingdom</option>
            <option value="Afghanistan" selected>Afghanistan</option>
            <option value="Aland Islands">Aland Islands</option>
            <option value="Albania">Albania</option>
            <option value="Algeria">Algeria</option>
            <option value="American Samoa">American Samoa</option>
            <option value="Andorra">Andorra</option>
  </select>

how to update multiple select values comma separated in database column.

Answer

<form method='POST' action='somepage.php'>
    <select name="specialization[]" multiple>
        <option value=""></option>
        <option value="United States" selected>United States</option>
        <option value="United Kingdom">United Kingdom</option>
        <option value="Afghanistan" selected>Afghanistan</option>
        <option value="Aland Islands">Aland Islands</option>
        <option value="Albania">Albania</option>
        <option value="Algeria">Algeria</option>
        <option value="American Samoa">American Samoa</option>
        <option value="Andorra">Andorra</option>
    </select>
    <input type='submit' value='submit'>
</form>

somepage.php

<?
$specialization = isset($_POST['specialization']) ? $_POST['specialization'] : [] ;
$totalSpec = sizeof($specialization);
for($i = 0; $i < $totalSpec; $i++){
    $spec = $specialization[$i];
    $query="INSERT INTO TableName SET SpecializationColumnName='$spec'";
}?>

OR

<?
$specialization = isset($_POST['specialization']) ? implode(",",$_POST['specialization']) : '';
$query = "";
if(!empty($specialization)){
   $query = "INSERT INTO TableName SET SpecializationColumnName='$specialization'";
}?>