Zarar Mahmud
Zarar Mahmud

Reputation: 197

How Do I show the change of data on the same webpage using PHP?

I am building a food ordering website like FoodPanda as a project. Now among all pages , I have my order screen which will have two parts. On one side it will show the food items , clicking on which will add the items to my cart and on the other side I will show my cart. Now, what I want to do is I want to show the items added on my cart as soon as I press a button which will add them and show it in the same page without refreshing the webpage. How do I achieve this?

Upvotes: 0

Views: 30

Answers (1)

mwaseema
mwaseema

Reputation: 118

You'll be using JavaScript and Ajax for doing this. When some user click on a product to add it to the cart you'll need to send a post request with product details to a PHP script from where the item will be added to the cart and some result is returned. The returned result can be used for making decision of whether the item was added to the card successfully or not. If it is, you can add the item on the cart side using the JavaScript.

Upvotes: 1

Related Questions