Site icon WDB24

PHP Shopping Cart – Setup Directory Structure and MYSQL Database

PHP

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


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.

Config.php

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.

Header.php

Footer.php

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.


Exit mobile version