Anonim / 2 years, 3 months ago | Download | Plaintext | Odpowiedz |

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
  <head>
    <title>View Records</title>
  </head>
  <body>
      <h1>View Records</h1>
      
            <?php
             error_reporting(E_ALL); 
             ini_set('display_errors','1');
$db = new PDO('mysql:host=localhost;dbname=records2', 'root', '');
$db -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$players = $db -> query('SELECT * FROM players');


                    echo "<table border='1' cellpadding='10>";
                    echo "<tr><th>ID</th><th>First name</th><th>Last name</th></tr>";
                    

                    foreach($players->fetchAll() as $row){
                        echo "<tr>";
                        echo "<td>".$row['id']."</td>";
                        echo "<td>".$row['firstname']. "</td>";
                        echo "<td>".$row['lastname']."</td>";
                        echo "</tr>";
}
$player -> closeCursor();
    
    echo "</table>";

?>
 
            
            
            
            
                   

      
  </body>
</html>