Re: Foreach
| From: | Nathan Nobbe | Date: | Thu, 17 Jan 2008 22:57:49 +0000 |
| Subject: | Re: Foreach | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-267518@lists.php.net to get a copy of this message | ||
On Jan 17, 2008 5:49 PM, Pastor Steve <smarquez@ccfortsmith.com> 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?
there are a few different issues here; first of all; are you sure
$_POST['name']
and $_POST['order'] are even arrays?
-nathan