Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

126
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda