Re: Foreach

From: Date: Fri, 18 Jan 2008 05:28:59 +0000
Subject: Re: Foreach
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-267527@lists.php.net to get a copy of this message
On Jan 17, 2008 11:40 PM, Jim Lucas <lists@cmsws.com> wrote: > Pastor Steve wrote: > > Here is my code: > > > > $name = $_POST['name']; > > if ($name) { > > foreach ($name as $t) { > > > > echo "$t"; > > } > > > > $order = $_POST['order']; > > if ($order) { > > foreach ($order as $i) { > > > > > > //Update the table in MySQL > > $update_data = "UPDATE sections SET order = > > '$i' WHERE name = > > '$t'"; > > $response = mysql_query( $update_data, $cnx ); > > if(mysql_error()) die ('database error<br>'. mysql_error()); > > > > echo "$i"; > > } > > > > } > > > > } > > > > I am trying to get the information in name and order to update the > database. > > So far, I can only get one or the other. Is there a way to do this? > > > > Thanks for your help. > > > > -- > > Steve M. > > > > Your example > > > > http://www.cmsws.com/examples/php/testscripts/smarquez@ccfortsmith.com/0001.php > > My solution > > > > http://www.cmsws.com/examples/php/testscripts/smarquez@ccfortsmith.com/0002.php > > Notice the differences > > Pay close attention to the form and see how I am nesting the fields in > the input name attribute. the topic of external variables, including the ability to create arrays from outside php, such as in GET and POST requests can be found here: http://www.php.net/manual/en/language.variables.external.php -nathan

« previous php.general (#267527) next »