NYCPHP Meetup

NYPHP.org

[nycphp-talk] Cycling through posted variables

Daniel Kushner nyphp at websapp.com
Thu Jul 11 10:06:29 EDT 2002


$_POST should be an array - not $var !


-----Original Message-----
From: Anirudh Zala [mailto:zala007 at hotmail.com]
Sent: Thursday, July 11, 2002 9:49 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] Cycling through posted variables


Hi.

This seems nice example..

but before using this function..first do check that that var is an array.
i.e. if u know that sometimes this vars will not have any key-value
sometimes.. then...before using foreach..check whether this is array ot
not..else it will giv error of "invalid arguments in for each loop" or
similar...

Thanks

Anirudh Zala

----- Original Message -----
From: "Daniel Kushner" <nyphp at websapp.com>
To: "NYPHP Talk" <talk at nyphp.org>
Sent: Thursday, July 11, 2002 7:01 PM
Subject: RE: [nycphp-talk] Cycling through posted variables


> foreach($_POST as $var => $val) {
> echo "The field named $var has the value $val<br>\
";
> }
>
> -----Original Message-----
> From: Brent Baisley [mailto:brent at landover.com]
> Sent: Thursday, July 11, 2002 9:05 AM
> To: NYPHP Talk
> Subject: [nycphp-talk] Cycling through posted variables
>
>
> I'm trying to cycle through the "fields" posted through a form submit. I
> need to cycle through the "fields" because I won't know the names of the
> fields since the field name actually represents a value. I tried going
> through the $HTTP_POST_VARS route and $_POST. Since this is suppose to be
an
> array, I thought I could cycle through using something like $_POST[0][1],
> but this doesn't seem to work.
> For testing, if I do $_POST["Game1"], then it works. Any ideas what I'm
> doing wrong or a better approach?
>
> Why do I need to do something like this? Well, I'm designing a system to
> handle a football pool I manage every year. This piece is for submitting a
> users picks for the week. I want the field name to be the Game ID and the
> value would be the Team ID. The picks screen uses radio buttons and the
user
> picks the winner for each game. All games for the week (~12) are displayed
> at once for convenience.
>
> I'm using PHP 4.1.2 (on OSX), but can upgrade if need be. I probably
should
> anyway.
>
> Thanks
> --
> Brent Baisley
> Systems Architect
> Landover Associates, Inc.
> Search & Advisory Services for Advanced Technology Environments
> p: 212.759.6400/800.759.0577
>





More information about the talk mailing list