checkbox array from loop - SOLVED
Posted: Fri Dec 08, 2006 2:43 pm
Hello,
Here's what the setup is: I have a list of items pulled from a table with a checkbox next to them. The user selects multiple checkboxes, clicks submit and the values are submitted to a different table. Simple enough but when I check multiple boxes, the only value submitted is the last checkbox. Should I put all the checkbox values into an array and submit that? If so, some guidance please.
[Please note the code is at the bare minimum now to make it easier for me to debug]
Thanks,
Pete
Here's what the setup is: I have a list of items pulled from a table with a checkbox next to them. The user selects multiple checkboxes, clicks submit and the values are submitted to a different table. Simple enough but when I check multiple boxes, the only value submitted is the last checkbox. Should I put all the checkbox values into an array and submit that? If so, some guidance please.
[Please note the code is at the bare minimum now to make it easier for me to debug]
Thanks,
Pete
Code: Select all
<?php
if(isset($_POST['add'])) {
$fintext = $_POST['finance'];
$query = "INSERT INTO fin_acc_final (fin_text) VALUES ('$fintext')";
mysql_query($query) or die (mysql_error());
}
?>Code: Select all
<?php
$query = ('SELECT * FROM fin_acc ORDER BY id ASC');
$result = mysql_query($query);
mysql_query($query) or die (mysql_error() . 'Cannot Retrieve Information');
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){
$id = $row['id'];
$fintext = $row['fin_text'];
echo '<input type="checkbox" name="finance" value="<li>' . $fintext .'</li>">' . $fintext . '<br />';
}
?>