Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/exercises/databaser/ovn_1/

andra.php
index.php
lagg_till.php
lista.php
ta_bort.php

lista.php

46 lines UTF-8 Windows (CRLF)
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>Lista med alla kompisar</title>
    <style>
        table, th, td {
            border: 1px solid black;
        }
    </style>
</head>

<body>
    <?php
    
try {
        
/** @var PDO $dbconn */
        
include("../dbconnection.php");
        
$sql "SELECT * FROM kompisar";
        
$info $dbconn->query($sql);
        echo (
"<table>
  <tr>
    <th>ID</th>
    <th>FÖRNAMN</th>
    <th>EFTERNAMN</th>
    <th>MOBILNR</th>
    <th>MEJL</th>
  </tr>"
);
        while (
$rad $info->fetch(PDO::FETCH_ASSOC)) {
            echo (
"<tr>
    <td>" 
$rad["id"] . "</td>
    <td>" 
$rad["f_namn"] . "</td>
    <td>" 
$rad["e_namn"] . "</td>
    <td>" 
$rad["mobil"] . "</td>
    <td>" 
$rad["mejl"] . "</td>
    </tr>
    "
);
        }
        echo (
"</table>");
    } catch (
PDOException $e) {
        echo (
$e->getMessage());
    }
    
?>
</body>

</html>