Guest User

Untitled

a guest
Apr 18th, 2018
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. getTeam.js
  2. -------------------
  3. $(document).ready(function(){
  4. $.ajax({
  5. url:"getTeam.php",
  6. dataType:"html",
  7. success:function(Result){
  8. $('#displaydata').html(Result)
  9. }
  10. })
  11. })
  12.  
  13.  
  14. getTeamsAjax.php
  15. --------------------------
  16. <!DOCTYPE html>
  17. <html>
  18. <head>
  19. <script type="text/javascript" src="getTeam.js"></script>
  20. <title></title>
  21. </head>
  22. <body>
  23. <h2>Teams</h2>
  24. <div id="displaydata"></div>
  25. </body>
  26. </html>
  27.  
  28. getTEams.php
  29. ------------------------------
  30. <?php
  31. $servername = "localhost";
  32. $username = "root";
  33. $password = "";
  34. $dbname = "worldcup2018";
  35.  
  36. // Create connection
  37. $conn = new mysqli($servername, $username, $password, $dbname);
  38. // Check connection
  39. if ($conn->connect_error) {
  40. die("Connection failed: " . $conn->connect_error);
  41. }
  42.  
  43. $sql = "SELECT * from teams";
  44. $result = $conn->query($sql);
  45.  
  46.  
  47.  
  48.  
  49. if ($result->num_rows > 0) {
  50. // output data of each row
  51. echo "<table border='1'>";
  52. echo "<tr>";
  53. echo "<td>Group</td>";
  54. echo "<td>Flag</td>";
  55. echo "<td>Name</td>";
  56. echo "<td>Outright</td>";
  57. echo "<td>FIFA Ranking</td>";
  58. echo "</tr>";
  59. echo "<tr>";
  60. foreach($result as $row){
  61. echo "<td>".$row["Stage"]."</td>";
  62. echo "<td><img height='20px' width='25px' src='images/".$row["Code"]."'</td>";
  63. echo "<td>".$row["Name"]."</td>";
  64. echo "<td>".$row["FIFARanking"]."</td>";
  65. echo "<td>".$row["OverallOdds"]."</td>";
  66. echo "<td>".$row["OverallOddsRank"]."</td>";
  67.  
  68. echo "</tr>";
  69. }
  70.  
  71. }else {
  72. echo "0 results";
  73. }
  74.  
  75. ?>
Add Comment
Please, Sign In to add comment