Jump to content

Array help


EchoFool

Recommended Posts

I am having difficulty understanding arrays. I read through page about them but didn't explain how to get it working via a form with checkboxes and inputboxes to set the array...

 

 

<input type="text" size="16" name="Quantity[<?=$Array?>]" value="">
<input type="checkbox" name="Checkbox[<?=$Array?>]" value="<?=$ItemID?>

 

I have this in a while loop that loads a list of items, and what it does is, it puts the itemID in the checkbox...so the selected checkboxes will have a list of ItemID's.

 

Then with that it is meant to grab the quantity from the Quantity input box adjacent to it.. so the array would end up forming like this:

 

Id     |   Quantity
2     |       34
5     |       2
6     |       23

 

I think i got it right with the above two lines but I don't know how to call it up on a processing page to use the data from the array

 

 

Link to comment
https://forums.phpfreaks.com/topic/93225-array-help/
Share on other sites

Only checked c/boxes are posted but you need to make sure that textbox[N] belongs with checkbox[N] so

<?php
$count=0;
while (.....) {
  <input type="text" size="16" name="Quantity[<?=$count?>]" value="">
  <input type="checkbox" name="Checkbox[<?=$count?>]" value="<?=$ItemID?>
   $count++;
}

Link to comment
https://forums.phpfreaks.com/topic/93225-array-help/#findComment-479492
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.