Dynamically created checkboxes, like text fields and other form elements, need to have unique name/value pairs, which I suspect is not happening in your code. If the name/value pairs are not unique, when the form is submitted the value from last form element with the non-unique name will be used by your data-processing script.
You're selecting the 'amID' and 'amenity' columns from the database table 'amenities'. (I'll assume that each row has a unique amID value; though that may not necessarily be true.)
// Build the query:
$query = "SELECT amID, amenity FROM amenities";
// Get a result identifier:
$result = mysql_query($query);
// Make sure there's a result identifier:
if($result) {
// I'll use _fetch_row() instead of _fetch_array() since there's a short, easy-to-manage column list in the result set:
while($data = mysql_fetch_row($result)) {
// To assure that each name/value pair is unique, we'll stick 'amenity_' at the beginning of each check box name.
// Then we'll stick the 'amID' value for each amenity onto the end of the name.
// The 'value' of the amenity will be the 'amID' value:
printf("%s: <input type=\"checkbox\" name=\"amenity_%s\" value=\"%s\"><br />",$data[1], $data[0], $data[0]);
}
// D'OH! Almost fergot... free up the resources from yer result set:
mysql_free_result($result);
}
// stick the rest of yer form in here...
Now, to 'extract' the values of the 'selected' amenities once the form is submitted, just loop through the $_POST vars (or $HTTP_POST_VARS, if you're using a version of PHP prior to 4.1.x):
// start an array for each user-world selected 'amenity':
$amens = array();
// loop thru the $_POST vars:
while(list($k,$v)=each($_POST)) {
// If the 'key' starts with amenity, add the 'value' to the array of selected amenities:
if(ereg("^amenity_", $k)) {
$amens[$k] = $v;
}
}
// now you should all of the selected amenities from the form inside an array named $amens.
// Do whatever you need to do with those selected values...
Got it? Kinda? Sorta?