You could edit $x, $y, $c, $v dynamically, then generate a query to insert it.
You could also take this part:
and change the $x part to the multi select field, so when its submitted, it will go through each value submitted, then you could do something like..
$Output = FALSE;
REPLACE:
foreach ($_POST[$x] as $v => $c)
with
$i = FALSE;
foreach ($_POST[$x] as $v => $c)
Replace echo "$x - $v - $c<br />";
with
$Output .= $c;
$i++;
if ($i < count($_POST[$x] - 1))
{
// Insert comma space if not at the end of the thing..
$Output .= ', ';
}
..
How exactly is this multi select setup?
Do you want to insert it into 1 column (above code)
or multiple rows, muliple columns?