Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
Add the price of all items bought by multiple number of users and store them to a variable

I have designed a basic website using HTML, CSS, javascript, and php for backend.

On the website, after a user logs in, he gets an option to buy some items(can be a single item or may be multiple items depending on the users choice).

My question is that if there are multiple number of users active on the website at any point of time, then is it possible to add the prices of all of the items bought by all of the active users and get the output in a single variable.

For example let's say only 2 users namely user 'a' and user 'b' are active at a given time and if user 'a' buys 2 items worth rupees 20 and 100, and the other user 'b' buys 3 items worth rupees 100, 200, and 300 then I want to add all the prices of items bought by both the users i.e. user 'a' and user 'b' in a variable named 'total' and its value should be 20+100+100+200+300=720.

Please guide on how to do this if it is possible to do so. Also if not possible in a variable then can it be possible to do so using the database.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

For a real time, you should use WebSockets It makes your server and your client side in relation via messages (without refresh page)

Include on client side JS : https://developer.mozilla.org/fr/docs/Web/API/WebSockets_API

And Include on server side PHP : https://www.php.net/manual/fr/book.sockets.php

It's used by any live chats for example, you store data on your socket server, and at any modification received from a client, your server recalculate and send the update to all client,

and then a JS scrpit modificate the DOMDocument with the received message.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!