Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index.php
- <?php
- $i = 0;
- $p_q = "SELECT * FROM `tournament_player` WHERE tournament_id = $tournament_id";
- $p_r = mysql_query($p_q) or die(mysql_error()); while ($p_g = mysql_fetch_array($p_r)) {
- echo "<li id=\"" . $p_g[player_id] . "\">";
- ?>
- <!-- GOALS -->
- <div class="eleven columns alpha">
- <div class="six columns alpha">
- Goal
- </div>
- <div class="two columns">
- <input type="submit" class="grey" id="score_<?php echo $i; ?>" value="<?php echo $p_g["goal"]; ?>" disabled />
- </div>
- <div class="three columns omega">
- <input type="hidden" id="tournament" value="<?php echo $tournament_id; ?>" />
- <input type="hidden" id="type" value="goal" />
- <input type="hidden" id="player" value="<?php echo $p_g["player_id"]; ?>" />
- <input type="button" class="green" value="+1" onclick="scoreGoal(this)" />
- <input type="button" class="yellow" value="-1" onclick="scoreGoal(this)" />
- <input type="button" class="red" value="0" onclick="scoreGoal(this)" />
- </div>
- </div>
- <!-- /GOALS -->
- submit.score.js
- function scoreGoal(elm, i){
- var elmScore = document.getElementById("score_"+i);
- var elmType = document.getElementById("type");
- var elmPlayer = document.getElementById("player");
- var elmTournament = document.getElementById("tournament");
- var url = "assets/_submitscore.php";
- var params = "id="+elm.value+"&score="+elmScore.value+"&type="+elmType.value+"&player="+elmPlayer.value+"&tournament="+elmTournament.value+"&rand="+Math.random();
- $.ajax({
- type: "POST",
- url: url,
- data: params,
- success: function(msg){
- elmScore.value = msg;
- }
- });
- }
- _submitscore.php
- <?php
- $id = $_POST['id'];
- //echo "id:" . $id;
- $score = $_POST['score'];
- //echo "score:" . $score;
- $type = $_POST['type'];
- //echo "type:" . $type;
- $tournament_id = $_POST['tournament'];
- //echo "tournament_id:" . $tournament_id;
- $player_id = $_POST['player'];
- //echo "player_id:" . $player_id;
- // her skal db bare opdateres, og ny værdi echo'es ud
- switch($id){
- case "0": $score = 0; break;
- case "-1": $score--; break;
- case "+1": $score++; break;
- }
- echo $score;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement