I have a form on my website, that uses an array to submit checkbox data. I then try to manipulate that data with a foreach loop to add a ":" to each checkbox data, and then I want to make that into a single string I can insert into a database.
This is my HTML code:
while($row = $result->fetch_assoc())
{
echo '<tr><td><input type="checkbox" name="pluginlist[]" value="'.$row['plugin'].'" /></td><td> '.$row['plugin'].'</td></tr>';
}
$row['plugin'] is data from a different table in the database.
This is my PHP code that $_POST the data, and then runs the foreach loop:
if(!empty($_POST['pluginlist'])) {
foreach($_POST['pluginlist'] as $plugins) {
$plugins1 = $plugins.":";
}
echo $plugins1;
}
The echo $plugins1 only echos the last checkbox data with a ":" on the end.
How can I make it so I can insert all the checkbox data into a database at once?