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...
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
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
For any queries comment down.