Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/databaser/databaser4/

cost.php
createtables.php
databaser4.php
deck.php
deletecost.php
deletedeck.php
deletepitches.php
display.php
pitches.php

display.php

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

<head>
  <meta charset="utf-8">
  <title>Display</title>

  <style>
    table {
      width: 50vw;
      color: black;
      border: 3px solid black;
    }

    table td {
      padding: 5px;
      border: 3px solid black;
      max-width: 50%;
    }

    #header td {
      background-color: gray;
      border-radius: 5px;
    }
  </style>

</head>

<body>
  <?php
  
include('../../../dbconnection.php');
      
  
$sql "SELECT * FROM deck
  LEFT JOIN pitches ON deck.pitch = pitches.pitch"
;
  
$stmt $dbconn->prepare($sql);
  
// fetch width column names, create a table
  
$data = array();
  
$stmt->execute($data);

  
$output "<table>" .
    
"<tr id='header'>" .
    
"<td>Namn</td>" .
    
"<td>Färg</td>" .
    
"<td>Defence</td>" .
    
"<td>Power</td>" .
    
"<td>Cost</td>".
    
"</tr>";
  while (
$res $stmt->fetch(PDO::FETCH_ASSOC)) {
    
$name htmlentities($res['name']);

    
$color "none";
    if (
null !== $res['color']) {
      
$color htmlentities($res['color']);
    }

    
$defence htmlentities($res['defence']);
    
$power htmlentities($res['power']);
    
$cost "none";
    if (
null !== $res['cost']) {
      
$cost htmlentities($res['cost']);
    }

    
$output .= "<tr>" .
      
"<td>$name</td>" .
      
"<td style='background-color:$color'>$color</td>" .
      
"<td>$defence</td>" .
      
"<td>$power</td>" .
      
"<td>$cost</td>" .
      
"</tr>";
  }
  
$output .= "</table>";
  echo 
"$output";

  
$dbconn null;
  
?>
</body>
</html>