Jump to content

Insert checkbox val + textbox val into db


somedude

Recommended Posts

Hello.

I have some dynamic checkboxes and corresponding textboxes.
[code]while($row=mysql_fetch_array($resu­lt2))
{

<td ><br/><br/><inpu­ t type="checkbox" name="valhere[]" value="<? echo $row[dec]; ?>"><? echo $row[dec]; ?></p></td>
<td width="53%" colspan="8"><input name="varv[]" value="" >[/code]


When a user ticks a checkbox and enters data into the corresponding textbox and submits, the value of the checkbox and textbox should be inserted into the database. I can insert the checkbox values perfectly, but the textbox values have issues.

[code]
while (list ($key,$val) = @each ($dec)) {
list ($key,$val2) = @each ($varv);
[/code]

That code will only input the ticked checkbox values perfectly, but if i've ticked checkbox 1, 3 and 5 (of the dynamic checkboxes) it loops 3 times and will only insert values from TEXTBOX 1,2,3 INSTEAD OF 1, 3, 5.

Can anyone point me in the right direction here? Thankyou gentlemen.
Link to comment
https://forums.phpfreaks.com/topic/33845-insert-checkbox-val-textbox-val-into-db/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.