I have an absolute beginner question here. I’m having trouble getting multiple checkbox entries into a single column in my database. I’ve tried a few different things with my php but can’t seem to get anything to work properly. I’ve tried using serialize as well as looked into using implode/explode. Sorry I’m basically asking to be spoon-fed because I know its a simple fix, I just haven’t been able to get anything to work yet. Any assistance would be appreciated. THANKS!!! Also The three checkboxes I have are system, comm, and other and I do have the brackets for my 3 inputs even though the php isn’t setup to handle them yet, so for now my DB is still showing Array for these inputs. Here is my php
<?php
$con = mysql_connect("localhost","Andrew","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mydb", $con);
$sql="INSERT INTO persons (firstname, lastname, modelid, system, department, comm, other, shift, comments)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[modelid]','$_POST[system]','$_POST[departme nt]','$_POST[comm]','$_POST[other]','$_POST[shift]','$_POST[comments]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con);
?>
So here is what I have used to get my multiple entries into a single cell in my db
('$_POST[firstname]','$_POST[lastname]','$_POST[modelid]','". implode(",", $_POST['system']) ."','$_POST[department]','". implode(",", $_POST['comm']) ."','". implode(",", $_POST['other']) ."','$_POST[shift]','$_POST[comments]')";So maybe this will serve someone in the future who is trying to accomplish this same simple goal, now my only problem is that the entries in the db are being cut off, I believe the solution is to serialize my arrays. THANKS AGAIN for all of your assistance!!