Forum Moderators: coopster
I have been working on a script that has select option however the name is not an array. EG:
<SELECT NAME="list21" MULTIPLE SIZE=10 onDblClick="moveSelectedOptions(this.form['list21'],this.form['list11'],false)">
When i click on submit all the selected option in the select box is passed in URL as iam using get. But I when i say
foreach ($_GET as $key => $value)
{
print "$key has a value of $value";
}
it only prints me the last value of the select box.
can someone please help me in getting this done, Iam at tight schedule, i did all teh left-right to get this but no luck
please help....
warm Regards
However - back to your problem -
have you tried to look at all of the $_GET variables to see what is getting passed over?
<pre>
<?php print_r($_GET);?>
</pre>
I am assuming that you are only getting 1 value sent through as there is only 1 value getting passed from the select statement, as that is the usual behaviour.
<SELECT NAME="list21[]" MULTIPLE SIZE=10 onDblClick="moveSelectedOptions(this.form['list21'],this.form['list11'],false)">
you can then use it as an array in PHP - one more thing, it would be better to post the form as you cant send an array on the query string.
Ally
[edited by: Scally_Ally at 4:24 pm (utc) on Aug. 10, 2007]
I don't want to make that select name as array by adding square brackets. (list21[])
Iam getting the values as index.php?list21=123&list21=222&list21=xyz in the url when i clk on submit.
when i say
$list_value = $_GET['list21']
echo $list_value
I get only xyz.
As mentioned earlier I have even tried with foreach but no luck.
Warm Regards
Ive tried to explain my problem on this thread: [webmasterworld.com...]
index.php?list21=123&list21=222&list21=xyz
Then you can manually parse the values out of the $_SERVER['REQUEST_URI'] value. You'd do something along these lines...
if(strpos($_SERVER['REQUEST_URI'], '?') !== false){
list($file, $query) = explode('?', $_SERVER['REQUEST_URI']);
$pairs = explode('&', $query);
foreach($pairs as $p){
$name = $val = '';
list($name, $val) = explode('=', $p);
if($name=='list21'){
$list21[] = $val;
}
}
}
echo '<pre>'; print_r($list21); echo '</pre>';