Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- getTeam.js
- -------------------
- $(document).ready(function(){
- $.ajax({
- url:"getTeam.php",
- dataType:"html",
- success:function(Result){
- $('#displaydata').html(Result)
- }
- })
- })
- getTeamsAjax.php
- --------------------------
- <!DOCTYPE html>
- <html>
- <head>
- <script type="text/javascript" src="getTeam.js"></script>
- <title></title>
- </head>
- <body>
- <h2>Teams</h2>
- <div id="displaydata"></div>
- </body>
- </html>
- getTEams.php
- ------------------------------
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "worldcup2018";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * from teams";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- echo "<table border='1'>";
- echo "<tr>";
- echo "<td>Group</td>";
- echo "<td>Flag</td>";
- echo "<td>Name</td>";
- echo "<td>Outright</td>";
- echo "<td>FIFA Ranking</td>";
- echo "</tr>";
- echo "<tr>";
- foreach($result as $row){
- echo "<td>".$row["Stage"]."</td>";
- echo "<td><img height='20px' width='25px' src='images/".$row["Code"]."'</td>";
- echo "<td>".$row["Name"]."</td>";
- echo "<td>".$row["FIFARanking"]."</td>";
- echo "<td>".$row["OverallOdds"]."</td>";
- echo "<td>".$row["OverallOddsRank"]."</td>";
- echo "</tr>";
- }
- }else {
- echo "0 results";
- }
- ?>
Add Comment
Please, Sign In to add comment