In need of some help here!!!!

Results 1 to 3 of 3

Thread: In need of some help here!!!!

  1. #1
    Join Date
    Dec 1969

    Default In need of some help here!!!!

    I&#039;m creating a shopping cart using cookies. (i&#039;m using a database)<BR><BR>1)If I pass the product ID accross with the QueryString how can it be added to the cookies?? <BR><BR>2)Can I then use this QueryString to select all the other information for this product (information in the same row)<BR><BR>3)Can many ID&#039;s be stored in the cookie so the shopper can buy more than one product. <BR><BR>4)How can I make a button to remove the products one at a time if the shopper chooses not to buy it.<BR><BR>5)Can all this information be listed in the shopping cart one after each other? (a list of products)<BR><BR>6) can the valuse that have already bean selected from the database be added together.<BR><BR>That is all!!!! (real easy)<BR><BR>Jacob

  2. #2
    Vijaya Seshan Guest

    Default RE: In need of some help here!!!!

    A1] Yes you can add the product Id passed through the querystring into a cookie. You can create a cookie whose value is the value of the product ID passed.<BR>A2]You can use the Product Id from the query string to retrieve the information from the database.<BR>A3]You can store multiple id&#039;s in cookie. One alternative is that you store this ID&#039;s as a comma separated list. Each time the shopper selects a item, check if that Id already exists in the cookie, if not then append it to the cookie.<BR>A4]Now if the shopper chooses to remove a product then you can modify the comma separated value in the cookie.<BR>A5]Once you have all the id&#039;s as a comma separated list use the split function to create an array of the Id&#039;s and then display the information from the database corresponding to the ID&#039;s.<BR>Hope this helps.

  3. #3
    MutantFish Guest

    Default RE: In need of some help here!!!!

    Hi Jacob, <BR><BR>What you need to be using is the Cookies collection. A good ASP book (something like one of the Teach Yourself ASP books) will help you out a lot. <BR><BR>However, in answer to some of your questions:<BR>1. On the page that you are passing to, have the following code:<BR><BR>strProductID = Request.Querystring("[name of the product id]")<BR><BR>Then you can add the strProductID to you cookie (I am assuming the cookie already exists!) like this: <BR><BR>Response.Cookies("strProductID") = strProductID<BR><BR>2.You can use the number you have passed over in the querystring to retrieve the other information on the product by connecting to your database and using a SQL statement.<BR><BR>If your product ID id stored in the database as a number, you would use: <BR><BR>SELECT * FROM [tablename] WHERE [productid] = "&strProductID<BR><BR>If your product ID isn&#039;t a number, but a string, or its stored in your database as a string, your SQL statement would have to look more like:<BR><BR>SELECT * FROM [tablename] WHERE [productid] =&#039;"&strProductID&"&#039;"<BR><BR>Questions 3, 4, 5, and 6 : you can do all of these things using the Cookies collection. Check out what 4guys has about the cookie collection, or visit this link on MSDN<BR>for some more sites that will be of use. <BR><BR>HTH,<BR>MutantFish

Posting Permissions

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