Re: Scroll through values sent from a form

From: Date: Tue, 04 Mar 2003 19:08:29 +0000
Subject: Re: Scroll through values sent from a form
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-138154@lists.php.net to get a copy of this message
$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 (#138154) next »