SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help adding items for a shopping cart script

    I'm building a simple shopping cart, no credit card at the moment, just a catelog with a table that shows the cost, shipping, etc.

    I got the catelog sorted out, displays all the necessary information, but having trouble figuring out how to do the bit when user clicks on the "Add" button.

    It'll probably use session to store the product code of the item. Something like session_register('$product_code'), but how would I make it remember how many of each item the user choice?

    Just couldn't figue out how to store the quantity to session of each item, and to effeciently show the person's basket. I'm not that good at making arrays...and php.net's description's just a bit hard to understand.

    Basically what I want to know how to go about setting it up so that it is like:

    $array[product] [number_of_product]
    Last edited by Robo; Jun 15, 2001 at 02:04.

  2. #2
    Node mutilating coot timnz's Avatar
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since I'll enivitably end up helping you tomorrow at your place anyway I won't try too hard , why not do something like this:

    <form>
    <input type="hidden" name="product" value="frogblender">
    <input type="hidden" name="number" value="83">
    </form>

    (obviously I have left somethings out in that)
    but then in your script you could go like this:

    $array = array($product, $number);
    // if you wanted to print/check it: print_r($array);

    I haven't used arrays before (except to fetch data out of database's, hehe), but there is probably an easier way to do this, so that your variables are already in an array.


Bookmarks

Posting Permissions

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