Jump to content

[SOLVED] array problem


mdnghtblue

Recommended Posts

I have a form with a list of items on a "market", and users can choose which and how many items to buy by filling in any of the fields and then clicking the submit button. Every input field is coded like this:

 

<input type="text" name="buy[<?=$item[id]?>]" size="6" value="0">

 

In the form handler function, I go through each value in buy[]:

 

$i = 0;
foreach($buy as $val)
{
	print "amount $i = $buy[$i]"; // debug

	if($buy[$i] != 0)
		buyItems($i, $buy[$i]);
	$i++;
}

 

The problem is that it doesn't go through every value, it stops after about 20 array values or less. (the first time I noticed this, it only went through about 20 array spots, right now it's at about 12, it keeps going down)

 

I checked to see if those other array values are just not going through the foreach loop, but those array spots don't exist. How come those fields aren't being put into the array?

Link to comment
https://forums.phpfreaks.com/topic/62248-solved-array-problem/
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.