Jump to content

For each error


Drewser33
Go to solution Solved by Psycho,

Recommended Posts

  • Solution

OK, you can't do a foreach() loop on a string, which is why you are getting the error. Are you allowing the user to make multiple customerID selections/entries? Did you name the fields appropriately so it will be sent as an array? E.g.

 

<input type="checkbox" name="customerID[]" value="33" />

Note the [] at the end of the input name

Link to comment
Share on other sites

echo '<option   value='.$row['ID'].'>'.$row['LastName'].', '. $row['FirstName'].'</option>';

This is part of a select box, so no, I did not have the [].

 

I will use a checkbox instead, that will likely be a better type of input instead, and I will use the [] as you mention. 

 

Thank you.  I will build the checkbox quickly and check it out.

Link to comment
Share on other sites

echo '<option   value='.$row['ID'].'>'.$row['LastName'].', '. $row['FirstName'].'</option>';

This is part of a select box, so no, I did not have the [].

 

I will use a checkbox instead, that will likely be a better type of input instead, and I will use the [] as you mention. 

 

Thank you.  I will build the checkbox quickly and check it out.

 

 

The same also holds for a select field that uses the multiselect parameter. You need to name the field with a [] at the end for the multiple values to be passed as an array.

 

<select name="customerID[]">

 

Also, I prefer to use double quotes when defining strings with variables

 

echo "<option value='{$row['ID']}'>{$row['LastName']}, {$row['FirstName']}</option>";

 

Whether you use a select list or a checkbox is a personal decision. I prefer using checkboxes since many users don't know how to make multiple selections in a select field.

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.