[nycphp-talk] how to pass the dynamic array indexes from one f orm to another in PHP 4.2
LS
lss1 at netzero.net
Mon Mar 10 16:17:14 EST 2003
hi;tracy:
it works now fine.
thanks
leo
----- Original Message -----
From: "Tracy" <tech_learner at yahoo.com>
To: "NYPHP Talk" <talk at nyphp.org>
Sent: Friday, March 07, 2003 1:43 AM
Subject: Re: [nycphp-talk] how to pass the dynamic array indexes from one f
orm to another in PHP 4.2
>
> Sure enough the code wont work, it didnt for me too until i made some
changes to it.
> for startes i wasnt able to understand this line
>
> for ($Counter=0; $Counter<$_POST['Number']; $Counter++)
>
> a $_POST for wot? but then i assumed this page might be called from some
other page n so did not ask for an explanation about it cos i was able to
run it after some modifications. this is the code that run for me..
>
> #code for dynamic.php
> <HTML>
> <HEAD></HEAD>
> <BODY>
> <FORM METHOD=GET ACTION="dynamic2.php">
> <?php
> //for ($Counter=0; $Counter<$_POST['Number']; $Counter++)
> //{
> $Offset = $Counter+1;
> //echo $Offset;
> echo "<BR>Please enter the name of child number $Offset";
> echo "<INPUT NAME=Child[] TYPE=TEXT><BR>";
> //}
> if ($Counter==0) echo"Press the button to move on";
> ?>
> <BR>
> <BR>
> <INPUT TYPE=SUBMIT name="test" >
> </FORM>
> </BODY>
> </HTML>
>
> #code for dynamic2.php (suggestion 1)
> <html>
> <body>
> <?
> foreach ($_GET['Child'] as $name) {
> print "$name<br>";
> }
> ?>
> </body>
> </html>
>
> # gives output
> <html>
> <body>
> Jerry<br></body>
> </html>
>
> #code u posted
> <HTML>
> <HEAD></HEAD>
> <BODY>
> <?
> $counter=1;
> foreach ( $_GET["Child"] as $c ) {
> echo "Child #". $counter++ ." is $c ";
> }
> ?>
> <BR>
> <BR>
> </BODY>
> </HTML>
>
> # gives output
> <HTML>
> <BODY>
> Child #1 is Jerry <BR>
> <BR>
> </BODY>
> </HTML>
>
> the other way i tried out the script was to include a number... heres wot
i did
> #dynamic.php
> <HTML>
> <HEAD></HEAD>
> <BODY>
> <FORM METHOD=GET ACTION="dynamic2.php">
> <?php
> $Number = 3;
> for ($Counter=0; $Counter<$Number; $Counter++)
> {
> $Offset = $Counter+1;
> //echo $Offset;
> echo "<BR>Please enter the name of child number $Offset ";
> echo "<INPUT NAME=Child[] TYPE=TEXT><BR>";
> }
> if ($Counter==0) echo"Press the button to move on";
> ?>
> <BR>
> <BR>
> <INPUT TYPE=SUBMIT name="test" >
> </FORM>
> </BODY>
> </HTML>
>
> #dynamic2.php
> <HTML>
> <HEAD></HEAD>
> <BODY>
> <?
> $counter=1;
> foreach ( $_GET["Child"] as $c ) {
> echo "Child #". $counter++ ." is $c <br> ";
> }
> ?>
> <BR>
> <BR>
> </BODY>
> </HTML>
>
> # heres the 'view source'
> <HTML>
> <HEAD></HEAD>
> <BODY>
> Child #1 is Tim <br> Child #2 is Tom <br> Child #3 is Tee <br> <BR>
> <BR>
> </BODY>
> </HTML>
>
> tried these ways, it sure works but the question is does it work in the
way u want? for that u'd have to tell wot exactly u r expecting as outputs
for what inputs. i am sorry, but ur objective isint clear to me.
>
> Tracy
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Coming together is a beginning...
> keeping together is progress...
> working together is success !!!
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, and more
>
>
> --- Unsubscribe at http://nyphp.org/list/ ---
>
>
>
More information about the talk
mailing list