This is a discussion on array inside a $_GET within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi to all, I'm starting to learn PHP. I'm not able to find a way to write an ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi to all,
I'm starting to learn PHP. I'm not able to find a way to write an array inside a $_GET or $_POST. I've tried: $_GET['Child[]']; {$_GET['Child[]']}; $_GET["Child[]"]; $_GET['Child']; .... nothing works. What is the correct syntax? Thank you! -- Maria Luisa C - 10/12/2003 15.11.18, here. http://fido.altervista.org/ Now playing: nothing, and savouring the silence. |
|
|||
|
Want to read an array from inside $_GET['Child'] ?
If that holds an array, you can use it as: $_GET['Child'][$index] (where $index is a valid index). Try to var_dump($_GET['Child']); -- Elias "MLC" <maluc52@yahoo.it> wrote in message news:18zxebyls60qs$.dlg@ID-187316.user.uni-berlin.de... > Hi to all, > I'm starting to learn PHP. > I'm not able to find a way to write an array inside a $_GET or $_POST. > I've tried: > $_GET['Child[]']; > {$_GET['Child[]']}; > $_GET["Child[]"]; > $_GET['Child']; > ... > nothing works. > What is the correct syntax? > Thank you! > -- > Maria Luisa C - 10/12/2003 15.11.18, here. > http://fido.altervista.org/ > Now playing: nothing, and savouring the silence. |
|
|||
|
Can you tell a something about the workaround? Why or for what do you need
this? "MLC" <maluc52@yahoo.it> schrieb im Newsbeitrag news:18zxebyls60qs$.dlg@ID-187316.user.uni-berlin.de... > Hi to all, > I'm starting to learn PHP. > I'm not able to find a way to write an array inside a $_GET or $_POST. > I've tried: > $_GET['Child[]']; > {$_GET['Child[]']}; > $_GET["Child[]"]; > $_GET['Child']; > ... > nothing works. > What is the correct syntax? > Thank you! > -- > Maria Luisa C - 10/12/2003 15.11.18, here. > http://fido.altervista.org/ > Now playing: nothing, and savouring the silence. |
|
|||
|
He donīt want to read a array he want to write an array into the $_GET var,
but makes no sin to me... "lallous" <lallous@lgwm.org> schrieb im Newsbeitrag news:br7aoj$4h3p$1@ID-161723.news.uni-berlin.de... > Want to read an array from inside $_GET['Child'] ? > If that holds an array, you can use it as: $_GET['Child'][$index] (where > $index is a valid index). > > Try to var_dump($_GET['Child']); > > -- > Elias > "MLC" <maluc52@yahoo.it> wrote in message > news:18zxebyls60qs$.dlg@ID-187316.user.uni-berlin.de... > > Hi to all, > > I'm starting to learn PHP. > > I'm not able to find a way to write an array inside a $_GET or $_POST. > > I've tried: > > $_GET['Child[]']; > > {$_GET['Child[]']}; > > $_GET["Child[]"]; > > $_GET['Child']; > > ... > > nothing works. > > What is the correct syntax? > > Thank you! > > -- > > Maria Luisa C - 10/12/2003 15.11.18, here. > > http://fido.altervista.org/ > > Now playing: nothing, and savouring the silence. > > |
|
|||
|
Il 10/dic/2003 Lars Raube ha scritto:
> Can you tell a something about the workaround? Why or for what do you need > this? First, thanks to all for your help. It is an exercise from an old book. There is a form (which ACTION is GET) with an array of text fields: <INPUT NAME=Child[] TYPE=TEXT> After submitting it, in the following php file the author refers to the variable array as $Child, but I know that now we have to write $_GET['variableName']. I've tried lallous' hint $_GET['Child'][$Count] and the error is: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\phpdev5\private\esercizi\dynamic2.php on line 9 Here's the code: <HTML> <HEAD></HEAD> <BODY> <?php $Count=0; echo "Your children's names are:"; do { echo"<BR><BR>$_GET['Child'][$Count]"; <--line 9: How I must write it? $CheckEmpty = "$_GET['Child'][$Count]"; $Count=$Count+1; } while ($CheckEmpty!=""); if ($Count==1) echo "Not Applicable"; ?> </BODY> </HTML> -- Maria Luisa C - 10/12/2003 16.17.59, here. http://fido.altervista.org/ Now playing: nothing, and savouring the silence. |
|
|||
|
You dont have to go that far, only $child = $_GET['child'];
$child will be an array because he take an array... :D <HTML> <HEAD></HEAD> <BODY> <?php if ($_GET['child']) { $child = $_GET['child']; echo "Your children's names are:"; for ($i=0;$i<count($child);$i++) { echo"<BR>$child[$i]"; } } ?> <form action="test.php" method="get"> <INPUT NAME=child[] TYPE=TEXT> <INPUT NAME=child[] TYPE=TEXT> <INPUT NAME=child[] TYPE=TEXT> <input type=submit> </BODY> </HTML> Savut "MLC" <maluc52@yahoo.it> wrote in message news:18zxebyls60qs$.dlg@ID-187316.user.uni-berlin.de... > Hi to all, > I'm starting to learn PHP. > I'm not able to find a way to write an array inside a $_GET or $_POST. > I've tried: > $_GET['Child[]']; > {$_GET['Child[]']}; > $_GET["Child[]"]; > $_GET['Child']; > ... > nothing works. > What is the correct syntax? > Thank you! > -- > Maria Luisa C - 10/12/2003 15.11.18, here. > http://fido.altervista.org/ > Now playing: nothing, and savouring the silence. |
|
|||
|
Il 10/dic/2003 Savut ha scritto:
> You dont have to go that far, only $child = $_GET['child']; > $child will be an array because he take an array... :D Grazie! :)) -- Maria Luisa C - 10/12/2003 18.08.57, here. http://fido.altervista.org/ Now playing: nothing, and savouring the silence. |
|
|||
|
you are welcome
Savut "MLC" <maluc52@yahoo.it> wrote in message news:8lne12h6dxzg$.dlg@ID-187316.user.uni-berlin.de... > Il 10/dic/2003 Savut ha scritto: > > > You dont have to go that far, only $child = $_GET['child']; > > $child will be an array because he take an array... :D > > Grazie! :)) > -- > Maria Luisa C - 10/12/2003 18.08.57, here. > http://fido.altervista.org/ > Now playing: nothing, and savouring the silence. |
|
|||
|
Hello MLC,
> echo"<BR><BR>$_GET['Child'][$Count]"; <--line 9: How I must write it? > $CheckEmpty = "$_GET['Child'][$Count]"; You cannot do that inside the string. You have to use an intermediate variable or use '{$var}' Anyway, re-write as: $count = count($_GET['Child']); for ($i=0;$i<$count;$i++) { $child = $_GET['Child'][$i]; echo "<BR><BR>$child"; } HTH Elias MLC <maluc52@yahoo.it> wrote in message news:<g4kf8ldj2rs1.dlg@ID-187316.user.uni-berlin.de>... > Il 10/dic/2003 Lars Raube ha scritto: > > > Can you tell a something about the workaround? Why or for what do you need > > this? > > First, thanks to all for your help. > It is an exercise from an old book. > There is a form (which ACTION is GET) with an array of text fields: > <INPUT NAME=Child[] TYPE=TEXT> > After submitting it, in the following php file the author refers to the > variable array as $Child, but I know that now we have to write > $_GET['variableName']. > > I've tried lallous' hint > $_GET['Child'][$Count] > and the error is: > Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting > T_STRING or T_VARIABLE or T_NUM_STRING in > c:\phpdev5\private\esercizi\dynamic2.php on line 9 > > Here's the code: > <HTML> > <HEAD></HEAD> > <BODY> > <?php > $Count=0; > echo "Your children's names are:"; > do > { > echo"<BR><BR>$_GET['Child'][$Count]"; <--line 9: How I must write it? > $CheckEmpty = "$_GET['Child'][$Count]"; > $Count=$Count+1; > } while ($CheckEmpty!=""); > if ($Count==1) echo "Not Applicable"; > ?> > </BODY> > </HTML> |
|
|||
|
Il 11/dic/2003 lallous ha scritto:
> You cannot do that inside the string. > You have to use an intermediate variable or use '{$var}' > > Anyway, re-write as: > $count = count($_GET['Child']); > for ($i=0;$i<$count;$i++) > { > $child = $_GET['Child'][$i]; > echo "<BR><BR>$child"; > } > > HTH Hello lallous, yesterday I solved it with the Savut's answer, anyway also your hint has been useful: thank you. -- Maria Luisa C - 11/12/2003 9.21.43, here. http://fido.altervista.org/ Now playing: nothing, and savouring the silence. |