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];
}

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?

check out this. http://www.banditssoftball.org/test.php
I'll get you the code later today

The problem is in the foreach statement. You cannot use varibles created inside of it on the outside. For this use the while statement. It should work then.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.