PHP4 session implementation of Mini shopping basket two _php tutorial

Source: Internet
Author: User
Requirements
You should know what a session is. If you don't know, here's a quick outline. There are a lot of articles on this topic that you can find all the code examples you need. Open a session on your start page, using $#@60; Php
Session_Start ();
? $#@62;
This will create a session name and a session ID. You can now either pass the session ID through a form using the default cookie-based settings session, or use it as a variable attached to your link (get method). Don't forget to release the session at the end. :)
Your product should have a name, price and unique identifier so that it can be used in this example, if not, you may need to make a little change. Here I use MySQL as the backend to build pages and others, which is not necessary in order for the shopping to work. :)
You should understand the array. Now if someone has time to take advantage of my code and create a class of it, I should be thankful to get it.
Defined
To simplify this example, I used four separate arrays and some extra variables. The code can be optimized. This makes it easy to display ideas and read code. You can use the class to do better, but I'm not quite sure if I can save the object to the session. Does anyone want to comment on this?
We also need a project counter. Of course you can use the count () command, I just think it's good enough to always know how many projects there are, and it also provides a good counter for loops.
Job
Let's assume that you have a list of items in your HTML page
ID Name Price
1 Mouse 25.00 Add
2 Key 100.00 Add
3 Car 5000.00 Add
4 Game 25.00 Add

http://www.bkjia.com/PHPjc/531753.html www.bkjia.com true http://www.bkjia.com/PHPjc/531753.html techarticle ask you to know what the session is. If you don't know, here's a quick outline. There are a lot of articles on this topic that you can find all the code examples you need ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.