Re: Update multiple records from a text field

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

 



Kaizer Boab wrote:

Hi Justin,

I only have the one qty field in the View Cart page. It is part of a loop to
pull out all the quantities from the cart. It is retrieved via the script
below:

 <?php
    // Query the cart table and select all the items from the table.
    $resultCart = mysql_query("SELECT * FROM cart, products WHERE
cart.albumId = products.albumId AND cart.trackerId = $trackerId ORDER by
products.albumTitle ASC");
    while($row_rsCart = mysql_fetch_array($resultCart))
    {
     $cost = $row_rsCart['albumPrice'] * $row_rsCart['qty'];
     $cost = number_format ($cost, 2);
     $subTotal = number_format ($subTotal, 2);
     $subTotal += $cost;
   ?>
            <tr>
              <td align="left"><?php echo $row_rsCart['albumArtist'];?></td>
              <td align="left"><?php echo $row_rsCart['albumTitle'];?></td>
              <td align="right"><?php echo $cost;?></td>
             <td align="right
                <input name="qty" type="text" size="2" value="<?php echo
$row_rsCart['qty'];?>" />
             </td>
            </tr>
            <?php  }// END while loop;?>

Since the qty text field is only one box in a loop, naming it won't help. Is
there another way I could achieve the update?

Thanx for your help.



Looks like you're naming all of your quantity text boxes "qty". You need
to use different var names to make multuple values come back. For
instance you could use "qty[]" to have the results come back in an
array. Or you could use qty[x] where x is a specific # so that you know
which product to update.

--
paperCrane <Justin Patrin>

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>

--
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