Change the input to be the following:
<input type="checkbox" name="sizes[]" value="small" />
<input type="checkbox" name="sizes[]" value="medium" />
<input type="checkbox" name="sizes[]" value="large" />
Then when you post the form, you'll get an array of sizes that are checked. You can [man]serialize/man that and store that in the database:
<?php
$sizes = serialize($_POST['sizes']);
Then when you get it back, you just need to [man]unserialize/man the column. So you might have code that looks like:
<?php $sizes = unserialize($db_row['sizes']); ?>
<input type="checkbox" name="sizes[]" value="small"<?php if(in_array('small', $sizes)): echo ' checked="checked"'; endif; ?> />
<input type="checkbox" name="sizes[]" value="medium"<?php if(in_array('medium', $sizes)): echo ' checked="checked"'; endif; ?> />
<input type="checkbox" name="sizes[]" value="large"<?php if(in_array('large', $sizes)): echo ' checked="checked"'; endif; ?> />
And saving the data would be:
<?php
$sizes = serialize($_POST['sizes']);
Then you'd store it in whatever column you'd like in your database.
Hope that helps.
Alternatively....
If you have a small number of options (like say 8 or fewer) could use some bitwise operators to do what you want. Give each option a value that is double the previous starting at 1. E.g.:
small - 1
medium - 2
large - 4
So then when they post the form, you can just sum up the values and store that number. Then to check you can use the bitwise "&" operator. So you can say if(2 & $sizes) then do something. E.g.
<?php
/* Sizes = 6 */
if($sizes & 1)
{
echo 'Small is selected!';
}
if($sizes & 2)
{
echo 'Medium is selected!';
}
if($sizes & 4)
{
echo 'Large is selected!';
}
In this case the output would be:
Medium is selected!Large is selected!
Just another simple option.