Tuesday, February 3, 2009
use of checkbox
if(!isset($_POST)) exit();
$selections = (isset($_POST['selection']))?$_POST['selection']:NULL;
$count = count($selections);
if($count > 5 ¦¦ $count < 1) { //checks to see if they selected more than 5
echo 'Danger Will Robinson!';
exit();
}
$query = 'INSERT INTO table (attribute1,attribute2,attribute3,attribute4,attribute5) valueS (';
$add = "'".implode("','",$selections)."'";
for($i = 0; $i < 5-$count; $i++) {
$add .= ",NULL";
}
$query .= $add.')';
echo $query;
?>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment