Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/ovning9/1/

laggatill.php
skapatabell.php
skriverut.php
tabort.php
uppdatera.php

skapatabell.php

38 lines ASCII Windows (CRLF)
<!-- createtable.php -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Create</title>
</head>

<body>
<?php
include ('../dbconnection.php');
try {

    
// sql to create table
    
$sql "CREATE TABLE kompisar (
    idnummer INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, 
    firstname VARCHAR(30) NOT NULL,
    lastname VARCHAR(30) NOT NULL,
    mobil INT,
    email VARCHAR(30) NOT NULL
    )"
;

    
// use exec() because no results are returned
    
$dbconn->exec($sql);
    echo 
"Table created successfully";
}
catch(
PDOException $e)
    {
    echo 
$sql "<br>" $e->getMessage();
}

//Rensa kopplingen till databasen
$dbconn null;

?>
  <a href="../ovn_sql1.php">Tillbaks till meny</a>
</body>
</html>