Forum Moderators: coopster
$sixty = "<input type=\"checkbox\" name=\"mychk[]\" value=\"sixty\">";
$hundred = "<input type=\"checkbox\" name=\"mychk[]\" value=\"hundred\">";
I then use code to see which boxes have been checked and insert them into the database..
if(!empty($_GET['mychk'])) {
echo 'You selected: ' . implode(',', $_GET['mychk']);
} else {
echo 'You didn\'t select anything.';
}
$query="INSERT INTO members (sixty, hundred) VALUES ('$sixty', '$hundred')";
mysql_query($query) or die('Error, insert query failed');
The page successfully echoes which boxes you have checked but the problem is that the values of the checkboxes are not being inserted into the database
can anybody help?
thanks
[edited by: jatar_k at 5:40 pm (utc) on Aug. 16, 2005]
[edit reason] removed code tags [/edit]
your vars should still be in the $_GET superglobal array so you will need to access them there
that query doesn't really make sense to me either. The columns are named sixty and hundred. What do you want to insert in there? yes and no? the same name as the column?
try this to see what you are looking for (I see your form is using GET, you might want to switch to POST)
if(!empty($_GET['mychk'])) {
echo 'You selected: ' . implode(',', $_GET['mychk']);
} else {
echo 'You didn\'t select anything.';
}
echo '<p><pre>';
print_r($_GET);
echo '</pre>';
$query="INSERT INTO members (sixty, hundred) VALUES ('$sixty', '$hundred')";
echo '<p>',$query;
mysql_query($query) or die('Error, insert query failed: ' . mysql_error());
those changes will help debug your script and see what is happening