How To Create Simple Shopping Cart Using PHP And MySQL

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys um welcome to my channel this is another tutorial on php and mysql on this tutorial i will show you how you can create damn some push up paint cutting i'm going to use bootstrap for my styling and if you're new to the standard please don't forget to click the subscribe button so that um you'll miss any tutorial from this channel right so let's dive into the tutorial okay so i have uh already created my database table okay so is the data in the table right so i created this had the name and their price and then i inserted the data into it manually right so this is the image then the price of the item and the name right so if you are new to your comments um shopping cart right so what you need to do to create new database and create a table and then click on insert and then reset um data manually by yourself right um so um these are here are the images right and read the images so you can see i have infinix here the prize and then the name of the image right and then the file extension right that's what you can see infinite.jfif right so you need to do this if you are new to um shopping carts right so that's what i want to show you so all you need to do is to create windows file and then um php then okay copy the css let's be the layout pass container 12. and here will be i'll show the shopping cart data here right so i'm going to let's okay class item selected text enter okay so let's run this car host okay okay that's how it looks like so um let's begin by making the connection so i will connect sqli connect so i'll print the data here so i should start everything here it's my query select storage from um yeah cut it okay results of course on my query connect and then the query variable hr so let me close the php tax and then open a new one here okay okay so let's print the data out so form a method to get action idea crosson oh id okay should i add the image uh img folder and then the image name um okay um height okay the name youtube page descending um price okay around it and let's see how it works um oh dave class caller md12 right so just copy this and cut and pay that here class and d4 don't close that okay let's see this time that's one size it's too much um it's um okay let's set that test to center take center okay so me how to cut beating one in value how to cut okay also on this data sorry okay okay input hidden the name equals name and then value click on copy that then paste it and then um change the name to price okay input number and request quantity value class from control okay okay so this is how i will print the data so that um users can add two cards so okay let me try to add to cart oh um made a mistake change a method to post okay now refresh it okay i do number five um what you need to do now is to um start the session because we are going to store the data in the session right so um if it said um add to cart okay and also if it said hours section okay the name of the session will be called us okay sessionary of course are so we store the data so use the get method to get the id right the name of the product the price and then the quantity right question area okay so let's see if this works session card let's try this on the web okay so you can see um the item that we had the id was three and you can see it here the name the price and then quantity one right and with this we can add new products we're going to write code for that right and what we do we need to do now is to get the idea of the session right so stationary id arrow column um session card and then we want the id right so id when you check it from the product you are adding is not in the irisu you can add it again get id stationary id okay with this um you can copy this and then paste it again okay so add new product okay add new so you can see how it works it's very simple that so you have four products so um what you need to do now is to build a table to display our card that you have been selected right so let's do that and we do that here so i have output because empty string to reveal some table simple html tags and classes okay tr they would um id to close the tag copy name item name then price quantity to that price action okay output if not empty session card for age okay so we display the items that we have instead here right so table data okay id so you can copy these two and paste name price quantity then um total price will be number format um um the price of our price [Music] times the quantity right okay so index.php action equals remove okay and id and the idea value id okay button remove an art class um so let's try this okay so i need to remove this okay so um is the table okay um cd horsepower to the price okay foreign uh quantity times the price right okay and then um close this tag okay cd href they got php um action of course go now class meeting morning and then let's write um quotes for delete and then clear all right so um let's add a php tags if you set get action get action equals section okay so let's try this okay it's working now so let's write code for delete get that of course removed session card value id because they get id right don't want to set session card key right okay that's our new product so remove remove okay btn block okay so this is how um i build my simple shopping cart and also um on my next tutorial i'll show you how i can build this using ajax so that the page will refresh before you get the item and also um thank you for watching and if this video was useful to you um don't forget to click on subscribe button and also share this tutorial and if you get an error let me know in the comments so that i can help you figure out right so see you in my next tutorial bye
Info
Channel: Programming With Dickson
Views: 37,159
Rating: undefined out of 5
Keywords:
Id: YloyMFPJyV4
Channel Id: undefined
Length: 34min 11sec (2051 seconds)
Published: Tue Feb 16 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.