Re: Scroll through values sent from a form

From: Date: Tue, 04 Mar 2003 19:19:03 +0000
Subject: Re: Scroll through values sent from a form
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-138155@lists.php.net to get a copy of this message
thanks for your reply but it doesn't work, i get the following output: INSERT INTO Table (Object, Object, Object, Object, ) Values (, , , , ) any ideas? "Bobby Patel" <anup_patel@rogers.com> wrote in message news:20030304190848.26621.qmail@pb1.pair.com... > $fields=''; > $values=''; > > foreach ($_POST as $field -> $value) { > $fields .= $field.", "; > $values .=$value.", "; > } > $fields = substr ($fields, -2); // strip off last comma and space > $values = substr ($values , -2); // strip off last comma and space > > $query = "INSERT INTO $_GET[table_name] (".$fields.") Values (".$values.")"; > > > "St" <shaun@mania.plus.com> wrote in message > news:20030304185819.11944.qmail@pb1.pair.com... > > Hi, > > > > Is it possible to scroll through values posted from a form using PHP? Here > > is my problem: I have a form on a page which is created dynamically from > the > > number of fields in a particular table, so when I POST the data how do I > > create the INSERT statement? I feel this will be awkward due to the > > construction of the INSERT statement and I would be very grateful for > > anyone's input. The form names are the same as the field alues in the > > table... > > > > It will need to be something like > > > > $query = " > > > > while (more Form Fields){ > > $query = $query + "'form fieldname'"; > > } > > > > $query = $query + ") VALUES ("; > > > > while (more POST Values){ > > $query = $query + "POST Value"; > > } > > > > $query = $query + ")"; > > > > I hope this makes sense to the reader! > > > > Thanks > > > > > > > > > >

« previous php.general (#138155) next »