Jump to content

Recommended Posts

I keep getting an invalid foreach argument here...

 

 

			case 'move_loc':
				foreach ($_POST[ 'move' ] as $key )
				{
					$update ("UPDATE recert SET location =" . $_POST[ 'location' ] . " WHERE serial =
'$key'");			
				}
			break;

 

 

My form uses 'move' as the checkbox names and I am attempting to update multiple rows at one time.  I do not have much experience with foreach so any help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/161862-solved-array-foreach-and-checkboxes/
Share on other sites

If the operand is not an arrray, then you're going to have an issue with foreach.  Under certain circumstances your $_POST['move'] probably either doesn't exist at all or isn't an array.  My recommendation for a quick examination of this is to use print_r() on the $_POST['move'] variable to understand what's happening better.

Be careful, cause you may want the value of each element of the array rather than the key.  You can obtain the value by adding this to your foreach loop:

 

foreach ($_POST['move'] as $key => $value)

 

NOTE - Click "topic solved" bottom left.

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.