Re: PHP Post & forms
| From: | Joe Henry | Date: | Fri, 14 Apr 2006 15:43:49 +0000 |
| Subject: | Re: PHP Post & forms | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-233991@lists.php.net to get a copy of this message | ||
On Thursday 13 April 2006 8:44 pm, Stephen Johnson wrote:
> On 4/13/06 7:40 PM, "Gary E. Terry" <terry@quickinet.net> wrote:
> > Quite possibly a stupid question, but here goes.
> >
> > I have a form that is a list of jobs. On that list is a
> > checkbox. The form field is named 'changedate'.
> >
> > I also have a hidden field called 'JobID'.
> >
> > What I am trying to accomplish is if a checkbox is
> > checked, when the form is submitted, I want all of
> > the JobID's to be updated by an SQL query.
> >
> > But it seems to me that $_POST will only contain
> > the last JobID in the form, no matter what. Am I correct
> > on this?
> >
> > Is what I am trying to accomplish not possible with a
> > form post?
> >
> > I think I remember doing something similar with Cold Fusion
> > years ago, but I have never attempted this with PHP.
> >
> > Any suggestions?
>
> You need to pass the checkboxes as an array value with the JobID as the
> identifier.
>
> Then on the other side, you can run through the list of JobID's and see
> which ones need to be updated.
>
If I'm understanding what you're asking, you have an array of checkboxes whose
values you want passed to you PHP via the $_POST array. The HTML form syntax
would be something like:
<input type="checkbox" name="array[]" value="..." />
<input type="checkbox" name="array[]" value="..." />
<input type="checkbox" name="array[]" value="..." />
etc.
Then in your PHP script, $_POST['array'] will hold an array of the checkbox
values.
HTH
--
Joe Henry
www.celebrityaccess.com
jhenry@celebrityaccess.com