Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multi-select, not allowing multi?

Status
Not open for further replies.

youradds

Programmer
Joined
Jun 27, 2001
Messages
817
Location
GB
I'm having a bit of a weird problem here. I have a select box (below);

Code:
        <select multiple size=&quot;10&quot; name=&quot;user_to_import&quot;>
        <option value=&quot;John:::Webb&quot;>John Webb</option>
        <option value=&quot;Paul:::Boemont&quot;>Paul Boemont</option>
        </select>

.. but when you select both these users, the data is passed on like;

index.php?action=guest_list_import_do&user_to_import=John%3A%3A%3AWebb&user_to_import=Paul%3A%3A%3ABoemont

Note: %3A is equal to : , so %3A%3A%3A equals :::

If I do the following therefore;

Code:
<?php

global $user_to_import;

foreach ($user_to_import as $_line) {

   echo &quot;User: $_line <BR>&quot;;

}

?>

That just prints out a parse error (invalid argument for foreach). Why is it not being assigned correctly to $user_to_import (i.e as an array) ???

I'm stumpred :(

Cheers

Andy
 
You need to add square brackets to send the multi-select to PHP via POST.
Code:
<select multiple size=&quot;10&quot; name=&quot;user_to_import
Code:
[]
Code:
&quot;>

I would advise to use POST as method and insepct the passed vars in the script it posts to with print_r($_POST);
 
OMg..I can't beleive I forgot to do that! Your a lifesaver :)

Cheers

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top