array inside a $_GET

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 ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-10-2003
MLC
 
Posts: n/a
Default array inside a $_GET

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.
Reply With Quote
  #2 (permalink)  
Old 12-10-2003
lallous
 
Posts: n/a
Default Re: array inside a $_GET

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.



Reply With Quote
  #3 (permalink)  
Old 12-10-2003
Lars Raube
 
Posts: n/a
Default Re: array inside a $_GET

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.



Reply With Quote
  #4 (permalink)  
Old 12-10-2003
Lars Raube
 
Posts: n/a
Default Re: array inside a $_GET

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.

>
>



Reply With Quote
  #5 (permalink)  
Old 12-10-2003
MLC
 
Posts: n/a
Default Re: array inside a $_GET

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.
Reply With Quote
  #6 (permalink)  
Old 12-10-2003
Savut
 
Posts: n/a
Default Re: array inside a $_GET

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.



Reply With Quote
  #7 (permalink)  
Old 12-10-2003
MLC
 
Posts: n/a
Default Re: array inside a $_GET

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.
Reply With Quote
  #8 (permalink)  
Old 12-10-2003
Savut
 
Posts: n/a
Default Re: array inside a $_GET

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.



Reply With Quote
  #9 (permalink)  
Old 12-11-2003
lallous
 
Posts: n/a
Default Re: array inside a $_GET

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>

Reply With Quote
  #10 (permalink)  
Old 12-11-2003
MLC
 
Posts: n/a
Default Re: array inside a $_GET

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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:00 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0