Advertisement
Guest User

Untitled

a guest
Oct 20th, 2011
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. index.php
  2. <?php
  3. $i = 0;
  4. $p_q = "SELECT * FROM `tournament_player` WHERE tournament_id = $tournament_id";
  5. $p_r = mysql_query($p_q) or die(mysql_error()); while ($p_g = mysql_fetch_array($p_r)) {
  6. echo "<li id=\"" . $p_g[player_id] . "\">";
  7. ?>
  8.  
  9. <!-- GOALS -->
  10. <div class="eleven columns alpha">
  11.  
  12. <div class="six columns alpha">
  13. Goal
  14. </div>
  15. <div class="two columns">
  16. <input type="submit" class="grey" id="score_<?php echo $i; ?>" value="<?php echo $p_g["goal"]; ?>" disabled />
  17. </div>
  18. <div class="three columns omega">
  19. <input type="hidden" id="tournament" value="<?php echo $tournament_id; ?>" />
  20. <input type="hidden" id="type" value="goal" />
  21. <input type="hidden" id="player" value="<?php echo $p_g["player_id"]; ?>" />
  22. <input type="button" class="green" value="+1" onclick="scoreGoal(this)" />
  23. <input type="button" class="yellow" value="-1" onclick="scoreGoal(this)" />
  24. <input type="button" class="red" value="0" onclick="scoreGoal(this)" />
  25. </div>
  26. </div>
  27. <!-- /GOALS -->
  28.  
  29.  
  30.  
  31.  
  32. submit.score.js
  33. function scoreGoal(elm, i){
  34. var elmScore = document.getElementById("score_"+i);
  35. var elmType = document.getElementById("type");
  36. var elmPlayer = document.getElementById("player");
  37. var elmTournament = document.getElementById("tournament");
  38.  
  39. var url = "assets/_submitscore.php";
  40.  
  41. var params = "id="+elm.value+"&score="+elmScore.value+"&type="+elmType.value+"&player="+elmPlayer.value+"&tournament="+elmTournament.value+"&rand="+Math.random();
  42.  
  43. $.ajax({
  44. type: "POST",
  45. url: url,
  46. data: params,
  47. success: function(msg){
  48. elmScore.value = msg;
  49. }
  50. });
  51. }
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. _submitscore.php
  60. <?php
  61. $id = $_POST['id'];
  62. //echo "id:" . $id;
  63. $score = $_POST['score'];
  64. //echo "score:" . $score;
  65. $type = $_POST['type'];
  66. //echo "type:" . $type;
  67. $tournament_id = $_POST['tournament'];
  68. //echo "tournament_id:" . $tournament_id;
  69. $player_id = $_POST['player'];
  70. //echo "player_id:" . $player_id;
  71.  
  72. // her skal db bare opdateres, og ny værdi echo'es ud
  73. switch($id){
  74. case "0": $score = 0; break;
  75. case "-1": $score--; break;
  76. case "+1": $score++; break;
  77. }
  78. echo $score;
  79. ?>
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement