Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda