Re: [PHP] GET question

2002-04-28 Thread Miguel Cruz

On Sun, 28 Apr 2002, Evan wrote:
 I pass parameters via querystring in this way:
 page.php?ID=5ID=6ID=23
 
 In $_GET[ID] I get only the value 23 
 I am surprised 'cause in ASP I get 5,6,23.
 
 Is there a way to make things working to have a sequence of values separated
 by commas?

page.php?ID[]=5ID[]=6ID[]=23

the [] tells it to make ID an array. Otherwise each value just replaces 
the previous one.

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] GET question

2002-04-28 Thread David Freeman

On 28 Apr 2002 at 23:30, Evan wrote:

 I pass parameters via querystring in this way:
 page.php?ID=5ID=6ID=23
 
 In $_GET[ID] I get only the value 23 

Unless you set ID as an array, which you haven't, you'll only keep 
the last value.  The simple answer is to have something like:

page.php?ID1=5ID2=6ID=23

although there's quite a few other solutions depending on what it is 
you're trying to do.

 Is there a way to make things working to have a sequence of values separated
 by commas?

Probably, but it's probably more effective to let us know what you're 
trying to do.  There's probably better ways to achieve the end result 
you're after.

CYA, Dave


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] GET question

2002-04-28 Thread Evan Nemerson

Thats because that query string is like saying:

$ID = 5;
$ID = 6;
$ID = 23;

If this is a form that you can't change the ID field names to ID1, ID2, ID3, 
etc. (which would probably be best) you could try something like:

?php

$args = explode( , $QUERY_STRING);
foreach ( $args as $argz )
{
$argv = explode( =, $argz);
unset( ${$argv[0]} );
}
foreach ( $args as $argz )
{
$argv = explode( =, $argz);
if ( !isset(${$argv[0]}) )
{
${$argv[0]} = rawurldecode($argv[1]);   
}
else
{
${$argv[0]} .= ,.rawurldecode($argv[1]);
}
}

?

That will first unset all the variables that were defined automatically by 
PHP, and do it how ASP does. It would be a better idea to store them in an 
array instead of a CSV string, but whatever floats your boat.


Evan Nemerson

PS nice name ;)




On Sunday 28 April 2002 14:30 pm, you wrote:
 Hi to all.

 I pass parameters via querystring in this way:
 page.php?ID=5ID=6ID=23

 In $_GET[ID] I get only the value 23 
 I am surprised 'cause in ASP I get 5,6,23.

 Is there a way to make things working to have a sequence of values
 separated by commas?
 Am I doing something wrong in PHP?

 Thanks for your help,
 Evan

-- 
Common sense is not so common.

Voltaire

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php