Re: Update multiple records from a text field
| From: | kaizer boab | Date: | Sat, 03 Apr 2004 17:42:59 +0000 |
| Subject: | Re: Update multiple records from a text field | ||
| References: | 1 2 3 4 5 6 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-23359@lists.php.net to get a copy of this message | ||
This has still got me stumped.
I tried the following script to update the table but I'm still experiencing
the same result, only one row updates, the rest remain unchanged.
while (list($k, $v) = each($qty))
{
$newQty = $v;
$update = "update cart set qty = $newQty WHERE trackerId = $trackerId AND
albumId = $albumId";
mysql_query($update);
}
I then tried changing my form field names on my View Cart page to
name="albumId[]" and name="trackerId[]" as well. I could view the results
using the array_multisort function with this script:
echo("<table border=\"1\">\n");
for ($i=0; $i < count($trackerId); $i++) {
echo("<tr><td>$qty[$i]</td><td>$albumId[$i]</td><td>$trackerId[$i]</td>\n");
}
echo("</table>\n");
But I am still confused as to how to get the script to update more than one
row.
> >>You need to use what I said in my reply. Change name="qty" to
> >>name="qty[]" or name="qty[some database id]".
> >>
> >>--
> >>paperCrane <Justin Patrin>
>
> Just try a print_r to see how it comes out and work from there. ;-)
>
> You'll have an array of values.
>
> --
> paperCrane <Justin Patrin>