[KLUG Members] (no subject)

bill members@kalamazoolinux.org
Fri, 18 Oct 2002 15:09:02 -0400


Randall Perry wrote:

> issue #2
> How do you handle issues on a PHP driven webform to display more input fields?

Add 'em.  That's not a PHP issue but a HTML issue

> I made an internal form here for RGA (return good authorization).  We need to
> be able to receive 1 or more items on a form and then insert them into the
> database (which I am going to have to create a seperate table for).  It is very
> similar to the line item list that would be needed for an online webform.  Any
> suggestions?

Don't know what you mean by a line item list, but if you have several items that
would create several records in the database just number the fields so you can
parse them later.  You can either do:

(I'm using - here  instead of > or < so the e-mail doesn't think they're tags)

-input type="text" name="item[0]"-
-input type="text" name="item[1]"-
-input type="text" name="item[2]"-

Or you can let php handle the numbering:

-input type="text" name="item[]"-
-input type="text" name="item[]"-
-input type="text" name="item[]"-


In either case, just run through the list when putting them in the db:

for ($i=0; $i<count($item);$i++) {
    $sql="insert into mydb (item) VALUES ('$item[$i]')";
    $result=mysql_query($sql);
    // error check here
}

kind regards,

bill