problem with to select multiple items

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • swethak
    New Member
    • May 2008
    • 118

    problem with to select multiple items

    hi

    i wrote a code to select multiple items in a drop down list.And i store all the items in my database.But in that i select multiple items and submit that items last item only stored.Please tell that what's the mistake in my code.

    [php]

    <td><select name="imagelist " id="imagelist" multiple="multi ple">
    <?
    while($row=mysq l_fetch_array($ result))
    {
    $i=1;
    $urlname=$row['urlname'];
    ?>

    <option value="<?=$urln ame?>"><?=$ext= strrchr($urlnam e,'/');?></option>

    <?
    }
    ?>
    </select>
    [/php]

    And i store these items in a database with a name $_POST['imagelist'].

    Anybody plz tell that whats the mistake in my code.plz help me.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Post the code you used to save the values.
    If you connect to the database say, through the command line, do you see all the values stored there or just the last one as well?

    Comment

    • swethak
      New Member
      • May 2008
      • 118

      #3
      Originally posted by r035198x
      Post the code you used to save the values.
      If you connect to the database say, through the command line, do you see all the values stored there or just the last one as well?

      i want to store all the items selected in drop down list.

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by swethak
        i want to store all the items selected in drop down list.
        You haven't answered my question and you still haven't posted the code you used to store the multiple values ...

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Now that I've looked at your code again, your select name should have [] added to it.

          i.e
          Code:
          <select name="imagelist[]" ....
          Then the code that retrieves it does something like
          Code:
          $imagelist = $_POST['imagelist'];
          and at that point imagelist is an array.

          Comment

          Working...