Re: Update multiple records from a text field

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kaizer Boab wrote:

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);
 }


for($i = 0; $i < sizeof($qty); ++$i) {
$update = 'update cart set qty = '.$qty[$i].' WHERE trackerId = '.$trackerId[$i].' AND albumId = '.$albumId[$i];
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>

-- paperCrane <Justin Patrin>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux