SELECT MULTIPLE only one in $_post

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oak Hall

    SELECT MULTIPLE only one in $_post

    foreach($_POST as $element=>$val)
    {
    echo $element.'--'.$val.'<BR>';
    }

    Where a select multiple html field had several selected values only shows
    one?? How do I get the others. php 5.1b

    Thanks
    Oak


  • Ken Robinson

    #2
    Re: SELECT MULTIPLE only one in $_post


    Oak Hall wrote:[color=blue]
    > foreach($_POST as $element=>$val)
    > {
    > echo $element.'--'.$val.'<BR>';
    > }
    >
    > Where a select multiple html field had several selected values only shows
    > one?? How do I get the others. php 5.1b[/color]

    How is your form defined?

    Ken

    Comment

    • Oak Hall

      #3
      Re: SELECT MULTIPLE only one in $_post

      Out take from the form, I get all the variables fine from the form, but the
      Multiple gives only one of the selected ones. Also
      print_r($_POST["Locations"]); shows only one value. Taking the same form
      pointing it to another server language (paradox) works fine. Thanks Oak


      <FORM name="searcher"
      ACTION="/php/ide/data/frontend.php?li b=mls&cmd=Prope rtySearchPost"
      METHOD="POST" >
      <input type="text" size="4" name="MinAcres" value="">
      <input type="text" size="4" name="MaxAcres" value=""><BR>
      <SELECT MULTIPLE NAME="Locations " SIZE="10">
      <OPTION SELECTED VALUE="All">All AREAS
      <OPTION VALUE=",2459">B raxton
      <OPTION VALUE="2459">&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;flatw oods
      (1)
      <OPTION VALUE=",2259,22 05,2206,2207">F ayette
      </SELECT>
      SUBMIT BUTTON
      </FORM>


      "Ken Robinson" <kenrbnsn@rbnsn .com> wrote in message
      news:1123427285 .400176.65270@g 14g2000cwa.goog legroups.com...[color=blue]
      >
      > Oak Hall wrote:[color=green]
      >> foreach($_POST as $element=>$val)
      >> {
      >> echo $element.'--'.$val.'<BR>';
      >> }
      >>
      >> Where a select multiple html field had several selected values only shows
      >> one?? How do I get the others. php 5.1b[/color]
      >
      > How is your form defined?
      >
      > Ken
      >[/color]


      Comment

      • Ken Robinson

        #4
        Re: SELECT MULTIPLE only one in $_post


        Oak Hall wrote:[color=blue]
        > Out take from the form, I get all the variables fine from the form, but the
        > Multiple gives only one of the selected ones. Also
        > print_r($_POST["Locations"]); shows only one value. Taking the same form
        > pointing it to another server language (paradox) works fine. Thanks Oak
        >
        >
        > <FORM name="searcher"
        > ACTION="/php/ide/data/frontend.php?li b=mls&cmd=Prope rtySearchPost"
        > METHOD="POST" >
        > <input type="text" size="4" name="MinAcres" value="">
        > <input type="text" size="4" name="MaxAcres" value=""><BR>
        > <SELECT MULTIPLE NAME="Locations " SIZE="10">[/color]

        Make the name an array:
        <select multiply name="Locations[]" size="10">
        [color=blue]
        > <OPTION SELECTED VALUE="All">All AREAS
        > <OPTION VALUE=",2459">B raxton
        > <OPTION VALUE="2459">&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;flatw oods
        > (1)
        > <OPTION VALUE=",2259,22 05,2206,2207">F ayette
        > </SELECT>
        > SUBMIT BUTTON
        > </FORM>
        >[/color]

        Then you're 'foreach' can be written:

        foreach ($_POST as $k=>$v) {
        echo $k
        if (is_array($k))
        foreach ($k as $k1=>$v1)
        echo '<br>[' . $k1 . ']' . ' = ' . $v1;
        else echo ' = ' . $v;
        echo '<br>';
        }

        Note: code untested.

        Ken

        Comment

        • Oak Hall

          #5
          Re: SELECT MULTIPLE only one in $_post

          THANKS!

          "Ken Robinson" <kenrbnsn@rbnsn .com> wrote in message
          news:1123428555 .816519.259610@ f14g2000cwb.goo glegroups.com.. .[color=blue]
          >
          > Oak Hall wrote:[color=green]
          >> Out take from the form, I get all the variables fine from the form, but
          >> the
          >> Multiple gives only one of the selected ones. Also
          >> print_r($_POST["Locations"]); shows only one value. Taking the same form
          >> pointing it to another server language (paradox) works fine. Thanks Oak
          >>
          >>
          >> <FORM name="searcher"
          >> ACTION="/php/ide/data/frontend.php?li b=mls&cmd=Prope rtySearchPost"
          >> METHOD="POST" >
          >> <input type="text" size="4" name="MinAcres" value="">
          >> <input type="text" size="4" name="MaxAcres" value=""><BR>
          >> <SELECT MULTIPLE NAME="Locations " SIZE="10">[/color]
          >
          > Make the name an array:
          > <select multiply name="Locations[]" size="10">
          >[color=green]
          >> <OPTION SELECTED VALUE="All">All AREAS
          >> <OPTION VALUE=",2459">B raxton
          >> <OPTION VALUE="2459">&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;flatw oods
          >> (1)
          >> <OPTION VALUE=",2259,22 05,2206,2207">F ayette
          >> </SELECT>
          >> SUBMIT BUTTON
          >> </FORM>
          >>[/color]
          >
          > Then you're 'foreach' can be written:
          >
          > foreach ($_POST as $k=>$v) {
          > echo $k
          > if (is_array($k))
          > foreach ($k as $k1=>$v1)
          > echo '<br>[' . $k1 . ']' . ' = ' . $v1;
          > else echo ' = ' . $v;
          > echo '<br>';
          > }
          >
          > Note: code untested.
          >
          > Ken
          >[/color]


          Comment

          Working...