Results 1 to 6 of 6

Thread: PHP Need help please

Threaded View

  1. #1
    Join Date
    Sep 2006

    PHP Need help please

    This coding...

    PHP Code:
    $content $_POST;
    $body '';
    $i=1$i $content['itemCount'] + 1$i++) {
    $name 'item_name_'.$i/* product name variable */
    $quantity 'item_quantity_'.$i/* product quantity variable */
    $price 'item_price_'.$i/* product price variable */
    $total $content[$quantity]*$content[$price]; /* product total price variable (price*quantity) */
    $grandTotal += $total/* accumulating the total of all items */
    $body .= 'Item #'.$i.': '.$content[$name]."\n".'Qty x '.$content[$quantity].' --- Unit Price $'.number_format($content[$price], 2'.''')."\n".'Subtotal $'.number_format($total2'.''')."\n"/* creating a semantic format for each ordered product */
    $body .= '=================================='."\n";

    Produces this....
    Item #1: 1-15+B-1
    Qty x 12 --- Unit Price $41.00
    Subtotal $492.00
    Item #2: 1-30+B-1
    Qty x 122 --- Unit Price $31.00
    Subtotal $3782.00
    Item #3: 1-0.5+HS+C
    Qty x 1 --- Unit Price $115.00
    Subtotal $115.00
    Which is exactly what I need BUT I also need to pull the individual elements into hidden fields in a button that will send this info to a shopping cart. My current code is:
    PHP Code:
    for($i=1$i $content['itemCount']+1$i++) {
    '<input type="hidden" name="Qty" value="'.$content[$quantity].'">
    <input type="hidden" name="Item" value="'
    <input type="hidden" name="Price" value="'
    <input type="hidden" name="Shipping" value="-1">'
    But this simply takes the last item and repeats it for as many times as their are items - if there are 3 items posted, it will repeat the 3rd item 3 times. How can I get it to output each of the 3 items?
    Last edited by NogDog; 09-18-2013 at 09:48 AM. Reason: added [php] and [code] tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center