jhylands

game.php

Mar 18th, 2013
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. <!-- page loaded assuming it is the users go !-->
  2. <body>
  3. <?php
  4. //startup scripts
  5. // Create connection to database
  6. include 'scripts/sql.php';
  7. //get list of users
  8. //$result = mysqli_query($con,"SELECT * FROM y" . $_GET['gid']);
  9. //while($row = mysqli_fetch_array($result))
  10. // {
  11. //     echo "<li>" . $row["prop1"] . "</li>";
  12. //  }
  13. echo $_GET['gid'];
  14. ?>
  15. <script>
  16. //allow the die to roll only once
  17. var rolled=false;
  18. //get the game id from the php to the javascript
  19. var id0 = <?php echo $_GET['gid']; ?>;
  20. function roll(){
  21. if(!rolled){
  22. var xmlhttp;
  23. if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  24. xmlhttp=new XMLHttpRequest();
  25. }
  26. else{// code for IE6, IE5
  27. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  28. }
  29. xmlhttp.onreadystatechange=function(){
  30. if (xmlhttp.readyState==4 && xmlhttp.status==200){
  31. var resp = xmlhttp.responseText;
  32. document.getElementById("die").innerHTML=resp;
  33. senddata(resp);
  34. }
  35. }
  36. xmlhttp.open("GET","die.php" ,true);
  37. xmlhttp.send();
  38.  
  39. rolled=true;
  40. }
  41.  
  42. }
  43. function senddata(dieval){
  44. dieval = dieval.substring(1,10);
  45. var req = "noti.php?id=" + id0 + "&id1=723872387" + "&prop1=" + dieval;
  46. var xmlhttp;
  47. if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
  48. xmlhttp=new XMLHttpRequest();
  49. }
  50. else{// code for IE6, IE5
  51. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  52. }
  53. xmlhttp.onreadystatechange=function(){
  54. if (xmlhttp.readyState==4 && xmlhttp.status==200){
  55. var resp = xmlhttp.responseText;
  56. //alert(resp);
  57. }
  58. }
  59. xmlhttp.open("GET",req ,true);
  60. xmlhttp.send();
  61.  
  62. }
  63. function End(){
  64. //alert('ending');
  65. if(rolled){
  66. alert('end');
  67. }else
  68. {
  69. alert('You must roll before ending your turn');
  70. }
  71. }
  72.  
  73. </script>
  74. <table border='1' width="100%" height="100%">
  75. <tr><td id="die" width="300px" onclick="roll();">Roll dice</td><td rowspan="6">
  76. <?php
  77. // Create connection to database
  78. include 'scripts/sql.php';
  79. //get users win/total
  80. $result = mysqli_query($con,"SELECT * FROM X" . $_GET['gid']);
  81. echo "<table><tr>";
  82. while($row = mysqli_fetch_array($result))
  83. {
  84. echo "<td>";
  85. echo "<img width='200px' src='https://graph.facebook.com/" . $row['id'] . "/picture' />";
  86. //get user's name
  87. $result1 = mysqli_query($con,"SELECT * FROM 'Persons' WHERE 'PID' = '" . $row['id'] . "'");
  88. while($row1 = mysqli_fetch_array($result1))
  89. {
  90. echo $row1['Firstname'] . " " . $row1['Lastname'];
  91. }
  92. echo $row['money'];
  93. echo "</td>";
  94. }
  95. echo "</tr></table>";
  96.  
  97. ?>
  98. </td></tr>
  99. <tr><td onclick="traid();">Traid</td></tr>
  100. <tr><td onclick="build();">build</td></tr>
  101. <tr><td onclick="End();">End turn</td></tr>
  102. <tr><td></td></tr><tr><td></td></tr>
  103. </table>
  104. </body>
Advertisement
Add Comment
Please, Sign In to add comment