I have this code to update the DB by subitting values in the checked columns
The problem is that it skips some entries and does not always subit the values entered
SQL Query
$thisid=$_POST['id'];
$nvalue = $_POST['newvalue'];
$chkd = $_POST['checked'];
foreach ($chkd as $key => $value) {
$sql="update invoice_subcategory set
Item_Cost='$nvalue[$value]'
where ID='$value'";
$query=mysql_query($sql,$db);
}
html form
<?php $query = "SELECT * from invoice_subcategory ORDER BY Cat_ID ASC ";
$result_costs = mysql_query($query) ;
while($costs = mysql_fetch_object($result_costs)){
$is_name = $costs->SubCategory;
$is_cost = $costs->Item_Cost;
$id = $costs->ID;
echo'<tr bgcolor='.$table_background_body.'>
<td>'. $is_name.'</td>
<td>'. $is_cost.'</td>';
echo"<td><input type='text' name='newvalue[]'> </td>
<td><input type='checkbox' name='checked[]' value=$id ></td>
</tr>";
see screen shots below