Web Analytics Made Easy -
StatCounter Help with enum entries in form - CodingForum

Announcement

Collapse
No announcement yet.

Help with enum entries in form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with enum entries in form

    Finally I got a script working that allows a user to enter data into the db via a form and submit button. Thing is, I have 2 fields in the db where the data is enum. At the moment the relevent line is :

    PHP Code:
    <input type=TEXT name="category" size=44MAXLENGTH=100
    However, there are 5 categories, and I would like a drop down list to let the user choose.

    How do I do this ???

    Cheers,

    Pha3dr0n

  • #2
    Code:
    <select>
    <option selected value="1">one</option>
    <option value="2">two</option>
    <option value="3">three</option>
    <option value="4">four</option>
    </select>
    My body's a temple... and like those ancient Greek ones it's a ruin
    sweenster.co.uk

    Comment


    • #3
      If you want to create the select-input dynamically...

      I created a function a few months ago but I didn't find it right now.
      I simplified the code of the function get_input_html of this class:

      http://www.purecodes.org/scripts/p4s...?class=.gforms

      Thats a class (well, three classes) I created to handle MySQL Queries easier in my codes and to create Forms easier by generating them by reading the MySQL Table properties.

      Here is a sample to generate a form by reading out the columns and properties of the table "test" in the database "test":

      PHP Code:
          include_once("p4s.php");
          include_once(
      "p4s.xport.php");
          include_once(
      "p4s.gforms.php");
          
          
      $myObj = new p4sgforms("test");
          echo 
      $myObj->gform_html_tbl("test"); 
      Pay attention to set correctly your database connection settings.

      hth, if not, ask here.
      www.united-scripts.com
      www.codebattles.org

      Comment


      • #4
        Cheers folks. I used sweensters advise initially, but will try piz's as soon as I get time.

        Pha3dr0n

        Comment

        Working...
        X