NYCPHP Meetup

NYPHP.org

[nycphp-talk] How to pass array when click on "submit" ?

Fernando Gabrieli fgabrieli at gmail.com
Tue Jan 27 12:20:26 EST 2009


suppose your input is names[]

foreach ($_POST['names'] as $name) {
<your code>
}

where $name has the value for each entry of the array

php.net/foreach

fernando

On Tue, Jan 27, 2009 at 2:16 PM, chad qian <nynj.tech at hotmail.com> wrote:

>  I am not sure how many "name","position",.."zip".I guess maybe I need
> foreach.How to program foreach here?
>
> Thanks!
>
> chad
>
> > Date: Tue, 27 Jan 2009 11:51:19 -0500
> > From: artur at marnik.net
> > To: talk at lists.nyphp.org
> > Subject: Re: [nycphp-talk] How to pass array when click on "submit" ?
>
> >
> > or you can just use:
> > <input name="name[1]" type="text" />
> > <input name="zip[1]" type="text" />
> > ....
> > <input name="name[2]" type="text" />
> > <input name="zip[2]" type="text" />
> > ....
> > <input name="name[3]" type="text" />
> > <input name="zip[3]" type="text" />
> >
> > then you will get an array after the post
> >
> > Artur
> >
> >
> >
> > David Mintz wrote:
> > >
> > >
> > >
> > >
> > > How to program php script to pass all these above
> > > information?"name","position","city","state" and "zip" are all
> > > array.
> > >
> > > Thanks!
> > >
> > > chad
> > >
> > >
> > >
> > > If city, state etc are all scalars, why do you want an array at all?
> And
> > > if you do want some or all of the form data wrapped into an array, you
> > > might want to use notation like
> > >
> > > <input name="person[name]" type="text" />
> > > <input name="person[zip]" type="text" />
> > >
> > > --
> > > David Mintz
> > > http://davidmintz.org/
> > >
> > > The subtle source is clear and bright
> > > The tributary streams flow through the darkness
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > New York PHP User Group Community Talk Mailing List
> > > http://lists.nyphp.org/mailman/listinfo/talk
> > >
> > > http://www.nyphp.org/show_participation.php
> > _______________________________________________
> > New York PHP User Group Community Talk Mailing List
> > http://lists.nyphp.org/mailman/listinfo/talk
> >
> > http://www.nyphp.org/show_participation.php
>
>
> ------------------------------
> Windows Live™: E-mail. Chat. Share. Get more ways to connect. Check it
> out.<http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_allup_explore_012009>
>
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> http://www.nyphp.org/show_participation.php
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090127/f0c35d36/attachment.html>


More information about the talk mailing list