Hi I have made a HTML Form with check boxes and text boxes for submitting data to the database table

Problem is it does not capture the values in the text boxes array but captures the one on the check boxes but the values in the text boxes is blank on submitting the form
Have tried a 1000 times and can't figure out what is happening some with an idea help.

HTML FORM CODE foe text box and check box
echo"<td><input type='text' name='newvalue[]'> </td>
<td><input type='checkbox' name='checked[]' value=$id ></td>


</tr>";


PHP script for processing the submitted results


//entered values array
$nvalue = $_POST;


foreach ($nvalue as $key => $value){
$nvalue[]=$value;
}


//checked values array
$chkd = $_POST;


foreach ($chkd as $key => $value){
$chkd[]=$value;
}


$size=count($chkd);



for($i=0;$i<$size;$i++)
{
$sql="update invoice_subcategory set Item_Cost='$nvalue[$i]'
where ID='$chkd[$i]'";
$query=mysql_query($sql,$db);
echo $sql."<br>";
echo $chkd[$i];
echo $nvalue[$i];
}

Edited 3 Years Ago by happygeek: fixed formatting

I can't see what you are wanting to accomplish with this code

foreach ($nvalue as $key => $value){
$nvalue[]=$value;
}

the following shows your array is just fine as it is

foreach ($nvalue as $key=>$value){
 echo $key."=".$value."<br>";
}

Why are you overwriting the array values?

This article has been dead for over six months. Start a new discussion instead.