> *The question: "How would you have multiple text input forms (on
> shopping cart page) with different inputted data (product quantities)
> submitted for querying the database (for changing the quantity of
> multiple products in the shopping cart at the same time)?**"*

easy, you can cause multiple text fields on the form with php compatible
array names.  Say you have a list of line items from your cart table and
the record ids (artificial keys of the cart table could be used in the
index).  Here is a sample couple of text fields;

<input type="text" name="quantity[5]" value="1">
<input type="text" name="quantity[14]" value="3">
<input type="text" name="quantity[8]" value="1">

the number 5, 14, and 8 represent the keys of the rows from your cart
table and when you pull the value from the post array after the user
submits the form, of course in addition to the quantities you should
show things like product descriptions and such on the same line as the
quantity text box.

$qtyupdates = $_POST["quantity"];

$qtyupdates above becomes an array with 3 rows in it and the recordd ids
are stored in the index.

A simple foreach loop

Foreach($qtyupdates as $idx => $qty) {
    $query = "update cart_table set itemqty = ".$qty
            ." where cart_lineid = ".$idx;
    mysql_query.... you get the rest
}

your form now becomes a list of line items with quantities in text boxes
for each item, and a single submit button allows you to apply all
changes at once.

Hope this is clear enough,

Warren Vail
Vail Systems Technology
http://www.vailtech.net

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

Reply via email to