PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > About MYSQL/PHP Shopping Cart's Product Quantity Change Input Forms
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
About MYSQL/PHP Shopping Cart's Product Quantity Change Input Forms

Réponse
 
LinkBack Outils de la discussion
Vieux 15/09/2007, 00h00   #1
Ji H. Park
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut About MYSQL/PHP Shopping Cart's Product Quantity Change Input Forms

*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)?**"*

*Here is an ideal example to clarify the matter:*
When a customer wants to change quantities of multiple products all at
once in the shopping cart, all the quantities has to be changed at the
same time just by clicking a button called (e.g. Update Quantity).

*Issue*: Currently I have update quantity buttons for each product,
which isn't convenient.

I would appreciate any tips, techniques, comments, or reference to any
website regarding this issue at your repository, thanks!

  Réponse avec citation
Vieux 15/09/2007, 00h07   #2
Gavin M. Roy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] About MYSQL/PHP Shopping Cart's Product Quantity Change Input Forms

Name all your input boxes the same thing, and include a similar level hidden
input:
<input type="hidden" name="sku[]" value="abc123" />
<input type="text" name="qty[]" value="1" />
<input type="hidden" name="sku[]" value="abc321" />
<input type="text" name="qty[]" value="2" />

on your POST


$_POST['sku'] && $_POST['qty'] will be arrays, and the ordering will be the
same so you can be sure of what index position/sku the qty is for.


On 9/14/07, Ji H. Park <kelvinpark86@gmail.com> wrote:
>
> *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)?**"*
>
> *Here is an ideal example to clarify the matter:*
> When a customer wants to change quantities of multiple products all at
> once in the shopping cart, all the quantities has to be changed at the
> same time just by clicking a button called (e.g. Update Quantity).
>
> *Issue*: Currently I have update quantity buttons for each product,
> which isn't convenient.
>
> I would appreciate any tips, techniques, comments, or reference to any
> website regarding this issue at your repository, thanks!
>


  Réponse avec citation
Vieux 15/09/2007, 00h30   #3
Warren Vail
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [PHP] About MYSQL/PHP Shopping Cart's Product Quantity Change Input Forms


> *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
  Réponse avec citation
Vieux 15/09/2007, 01h58   #4
brian
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] About MYSQL/PHP Shopping Cart's Product Quantity ChangeInput Forms

Ji H. Park wrote:
> *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)?**"*
>
> *Here is an ideal example to clarify the matter:*
> When a customer wants to change quantities of multiple products all at
> once in the shopping cart, all the quantities has to be changed at the
> same time just by clicking a button called (e.g. Update Quantity).
>
> *Issue*: Currently I have update quantity buttons for each product,
> which isn't convenient.
>
> I would appreciate any tips, techniques, comments, or reference to any
> website regarding this issue at your repository, thanks!
>


Don't provide a button at all. Place the quantity for each item in a
text input field so that it may be edited by the user before submission.
I'm guessing that your page may presently be showing the details of the
item(s) as, say, a regular HTML table, with hidden form fields for the
data. But, instead of having the quantity hidden, place it in a normal
field. This way, any, all, or none of the quantities may be updated in
one POST.

Or, if your cart resides solely in $_SESSION, you may still provide the
quantity fields and update later.

brian
  Réponse avec citation
Vieux 15/09/2007, 14h26   #5
tedd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] About MYSQL/PHP Shopping Cart's Product Quantity ChangeInput Forms

At 4:00 PM -0700 9/14/07, Ji H. Park wrote:
>*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)?**"*
>
>*Here is an ideal example to clarify the matter:*
>When a customer wants to change quantities of multiple products all
>at once in the shopping cart, all the quantities has to be changed
>at the same time just by clicking a button called (e.g. Update
>Quantity).
>
>*Issue*: Currently I have update quantity buttons for each product,
>which isn't convenient.
>
>I would appreciate any tips, techniques, comments, or reference to
>any website regarding this issue at your repository, thanks!



In addition to what others have said, use javascript to adjust
quantities and cost until the user wants to submit like so:

http://webbytedd.com/c/form-calc/

There's little reason to make the user click "Update Quantity"
repeatedly before the user is finished with his/her order IF you are
offering several items -- like found in a shopping cart.

After the user clicks submit, then use php to make sure the data is
what you expect.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h37.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11350 seconds with 13 queries