populate drop down box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bips2005
    New Member
    • Jul 2008
    • 19

    populate drop down box

    i need to populate drop down box with database values. i have a field customername from table customer and i want a function that populates drop down in html with the values of this field. we have to use pear and it is making a little complicated
  • realin
    Contributor
    • Feb 2007
    • 254

    #2
    you dont have to use perl for this, i suppose

    and populating a drop down is fairly easy in php.

    [PHP]
    1. connect and fetch data from database
    2. store the result in an array .. say $result
    now
    echo "<select>
    foreach($array as $data){
    echo "<option>$d ata[customername]</option>";

    }
    echo "</select>";
    [/PHP]

    the above code should do the needful, i preassume that steps 1,2 are clear.

    cheers !!

    Comment

    • bips2005
      New Member
      • Jul 2008
      • 19

      #3
      Originally posted by realin
      you dont have to use perl for this, i suppose

      and populating a drop down is fairly easy in php.

      [PHP]
      1. connect and fetch data from database
      2. store the result in an array .. say $result
      now
      echo "<select>
      foreach($array as $data){
      echo "<option>$d ata[customername]</option>";

      }
      echo "</select>";
      [/PHP]

      the above code should do the needful, i preassume that steps 1,2 are clear.

      cheers !!
      i didn't mean perl i meant peardb but thank you your code was helpful

      Comment

      • realin
        Contributor
        • Feb 2007
        • 254

        #4
        Originally posted by bips2005
        i didn't mean perl i meant peardb but thank you your code was helpful
        hehehe... my mistake on that pear & perl issue, sometimes i read too fast and preassume certain words :D

        Comment

        • bips2005
          New Member
          • Jul 2008
          • 19

          #5
          Originally posted by realin
          hehehe... my mistake on that pear & perl issue, sometimes i read too fast and preassume certain words :D
          its ok....no harm done

          Comment

          Working...