www.webdeveloper.com
Results 1 to 3 of 3

Thread: multi select and php

  1. #1
    Join Date
    Jan 2004
    Posts
    377

    multi select and php

    It must be something I cant see. It is driving me nuts.

    I have these 2 values in a form

    PHP Code:
                <select name="existingPlayer[]" multiple="true" >
                    <?php
                    $query 
    "edit";
                    
    $results querydatabase ($query);
                    while(
    $row mysql_fetch_assoc($results))
                    {
                        echo 
    "<option value=\"".$row["player"]."\">".$row["player"]."</option>";
                    }
                    
    ?>
                </select>
                <input type="text" name="player" size="100" maxlength="100" /></td>
    the form returns

    Code:
    ["existingPlayer"]=>  string(12) "Aaron Rowand" ["player"]=>  string(14) "fsfgdgdfgsgdsg"
    my code to read it is

    PHP Code:
                $players $_POST["player"];
                
    $playersTemp $_POST['existingPlayer'];
                
    var_dump(@playersTemp);
                if (
    $playersTemp)
                {
                    echo 
    "<br />1<br />";
                    foreach (
    $playersTemp as $player)
                    {
                        echo 
    "<br />2<br />";
                        
    $players $player."/".$players;
                    }
                } 
    I am never getting to the 2 above.

    What am I doing wrong? I have been looking at this for a while and something this simple shouldn't be this problematic.

    tia
    Last edited by DARTHTAMPON; 01-11-2010 at 08:56 PM.

  2. #2
    Join Date
    Oct 2003
    Posts
    381
    I am never getting to the 2 above
    which '2' are you referencing to? Are you referencing to the variables? or that it's not outputting the code, which I'm not sure if you're outputting this elsewhere but you don't echo $players = $player."/".$players;. Anyways, wanna clarify a little? Or you get it fixed?

  3. #3
    Join Date
    Dec 2009
    Location
    Denmark
    Posts
    240
    You could try to put selected='selected' in all the options that you wish to parse along during the request.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles