Form help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kf4pfw@gmail.com

    Form help

    I need to create a form that contains multiple lines for the same
    data....an array looks like the answer.

    My form:

    Date Name Title Phone
    =============== =============== ======
    _____ ________ _________ ________


    My first though was to have variables:

    date, name, title, phone, date1, name1, title1, date1,
    date2,name2,tit le2,phone2,date 3,name3,title3, date3

    etc so that I can have 10 "lines" for the user to enter this data into.
    Some will enter 1 line, others all 10.

    So far, my clunky methods work....however trying to decide how many
    lines they have filled out led me to thinking "perhaps I should use an
    array instead".

    This data is submitted to a database (mysql on linux) and I am not sure
    if even that will work.

    My question is HOW can I build a form that contains 4 fields that could
    be repeated across numerous lines....then put it all into a db for
    retrieval later?

    Hope my question isn't too confusing!

    kf4pfw

  • Alvaro G. Vicario

    #2
    Re: Form help

    *** kf4pfw@gmail.co m escribió/wrote (8 Sep 2004 13:55:09 -0700):[color=blue]
    > My question is HOW can I build a form that contains 4 fields that could
    > be repeated across numerous lines....then put it all into a db for
    > retrieval later?[/color]

    You said it all yourself, arrays ;-)

    Just add [] to HTML field names and PHP will treat is as an array:

    <input name="date[]"><input name="name[]">...
    <input name="date[]"><input name="name[]">...
    <input name="date[]"><input name="name[]">...
    <input name="date[]"><input name="name[]">...
    <input name="date[]"><input name="name[]">...
    ....



    Then $_FORM['date'] is an array, $_FORM['name'] is another, etc.


    --
    -+ Álvaro G. Vicario - Burgos, Spain
    +- http://www.demogracia.com (la web de humor barnizada para la intemperie)
    ++ Las dudas informáticas recibidas por correo irán directas a la papelera
    -+ I'm not a free help desk, please don't e-mail me your questions
    --

    Comment

    Working...