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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.