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

195
Visualizações
Live Update Score On a php Score board for user

I want live score board screen in php. I have completed all on click button + or - score board is dynamically change score. But we need to refresh page look latest score. I want as we click + or - button to change score that score should be directly update score on screen for user without refreshing page. What is the solution? Is there a code for this purpose. Please help me. Thanks...

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It's hard to answer without having knowledge on how actually you have implemented your code, I can only give basic idea on this.

You need 3 files for this, as

  1. main.html:- where the scoreboard is included.
  2. scoreboard.php:- where the scoreboard is shown.
  3. updateSB.php:- where the scoreboard is updated.

main.html

<div class="somediv">
  <div class="scoreboard" id="scoreboard">
  <!--This is the division I will load scoreboard dynamically-->
  </div>
</div>
<script>
 //Loading initial scoreboard here
 $('#scoreboard').load("scoreboard.php");
 //Now do ajax calls for '+' '-' buttons (onclick) here
 $.post("updateSB.php",{type : "plus/minus"},
 function(data, status){
   if(status=="success"){
     //Loading scoreboard for every update
     $('#scoreboard').load("scoreboard.php"); 
   }
 });
</script>

scoreboard.php

<div class="scoreboard">
  <div class="header">Some team <?echo $team1;?> vs team <?echo $team2?></div>
  <div class="body">
    some sort of table score here?
    Score :- <?echo $score;?>
  </div>
  <div class="footer"></div>
</div>

updateSB.php

<?
//Here is where you update ur scoreboard
if(isset($_POST['type']){
  if($_POST['type']=="plus"){
  //Perform plus on score
  }
  elseif($_POST['type']=="minus"){
  //Perform minus on score
  }
}
?>

Points to remember

  1. Use ajax in proper way ie, do right request and handle the request at backend correctly.
  2. Implementation of dynamic scoreboard is possible if you are using some global variables or database at the backend.

For any queries comment down.

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