View Full Version : Multiple Checkboxes in PHP

07-16-2009, 04:43 PM
I am working on an array of checkboxes that all values need to be added to my database. I am new to PHP and seem to be missing something. I hope someone has the time to help me.
This is my code so far. It works fine to display the echo $string but I just need to know how to add it to a field in my table in my database... Thanks

<form method="POST" name="form">
<input type="checkbox" value="box1" name="cbox[]" />
<span class="Footer">Box1</span><br/>
<input type="checkbox" value="box2" name="cbox[]" />
<span class="Footer">Box2</span><br/>
<input type="checkbox" value="box3" name="cbox[]" />
<span class="Footer">Box3</span><br/>
<input type="checkbox" value="box4" name="cbox[]" />
<span class="Footer">Box4</span><br/>
<input type="submit" value="Select Above and Click Me" />
<input name="ID" type="hidden" id="ID" value="<?php echo $row_Recordset1['ID']; ?>" />

if(isset($_POST['cbox'])) {
$checkboxes = $_POST['cbox'];
$string = implode($checkboxes,"<br>");
echo $string;


07-16-2009, 05:02 PM
Moved post to PHP board

07-17-2009, 01:18 AM
you need to use an insert or update statement to add it to your database.
add an 'action' to your form to point to the page you add the script on and when you submit it will fire the script