954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Creating a Simple Shopping cart

Helloo

Im new in Databases.
I want to create a simple shopping cart i have a table called product

CREATE TABLE  `products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `category` varchar(150) NOT NULL,
  `name` varchar(100) NOT NULL,
  `author` varchar(100) NOT NULL,
  `details` varchar(10000) NOT NULL,
  `price` int(11) NOT NULL,
  `imgpath` varchar(500) NOT NULL,
  `dateadded` date NOT NULL,
  `stock` int(11) NOT NULL,
  PRIMARY KEY (`id`)
)


what i want is when i click the add to cart button the product must add to a cart i don't have a idea how to do this

ruwanaru
Junior Poster in Training
67 posts since Mar 2009
Reputation Points: 10
Solved Threads: 1
 

Why don't you use the paypal cart cms or if you want it custom made then perhaps download a pre-made cart and see how they did it. But as for how to insert the item simply use the mysql_query("INSERT INTO `table` SET `column`='value', `another`='value2'");
Also you will need to send the user a cookie for identification.

cwarn23
Occupation: Genius
Team Colleague
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
 

I used a tutorial I found online to begin building my first shopping cart - it basically explains how to create a session-based 'cart' that a user can add products to. From there, it's up to you to learn how to take that cart and convert it into an order etc.

Here's the link: http://v3.thewatchmakerproject.com/journal/276/building-a-simple-php-shopping-cart

It's a fairly basic tutorial and it doesn't cover the likes of security etc. - you'll want to look into that as well! Hope it helps somewhat though :)

Benjip
Newbie Poster
13 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: