PHP Shopping Cart – Setup Directory Structure and MYSQL Database

This is my second tutorial in PHP shopping cart series. In this post we will setup directory structure and mysql database. I will also create database table and will insert records. So let’s start.

First I need to create following 3 folders:

  1. Assets Folder: This folder has javascript, css and product images
  2. Inc Folder: This folder has config and helper file
  3. Layouts: This folder has header and footer file

Once I created all of the three folders, my root folder is look something like this

php shopping cart basic folder structure

Next we have to setup database and mysql tables. First let’s create a database

Now let’s create a products, product_images, order and order_details table.

We have successfully created database and mysql tables. Now let’s create a database connection in php file. Go to inc folder and create config.php and add PHP PDO connection.


I have createed config.php. Now I will be creating helpers.php file in inc folder. Helpers.php file will have custom php functions which I will use later.

Now create a header.php and footer.php file in layouts folder.



So now, We have setup our basic shopping cart structure and setup database. In the next tutorial I will show you how get product from database and display.


Posted in PHP

Leave a Reply

Your email address will not be published. Required fields are marked *