Checkboxes - Storing data in mysql
Posted: Fri Sep 30, 2005 8:51 pm
Hi there,
I have a form that uses checkboxes, but I'm having a problem storing the data in MySQL.
First, I'm looking up values in a table to create the checkboxes:
Then, I try this:
But, when I try to insert the data into MySQL, it inserts the blank (even when the boxes are checked).
Can someone help out here?
I have a form that uses checkboxes, but I'm having a problem storing the data in MySQL.
First, I'm looking up values in a table to create the checkboxes:
Code: Select all
function fn_1 ()
{
echo "QUESTION_ONE";
$query = "SELECT DISTINCT(fn_1) FROM choices where fn_1!=''";
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
echo "<dt><input type=\"checkbox\" id=\"fn_set_1[]\" value=\"{$row['fn_1']}\">{$row['fn_1']}<br />\n";
}
echo "<p>";
}Code: Select all
if (isset($_POST['fn_set_1'])) {
$FN1=implode(',',$_POST['fn_set_1']);
} else {
$FN1='';
}Can someone help out here?