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
createtables.php
77 lines ASCII Windows (CRLF)
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Create</title>
</head>
<body>
<?php
include ('../../../dbconnection.php');
// Skapar garage-tabellen
try {
// sql to create table
$sql = "CREATE TABLE deck (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(30) NOT NULL,
pitch VARCHAR(4),
defence VARCHAR(4),
power VARCHAR(4),
cost VARCHAR(4)
)";
// use exec() because no results are returned
$dbconn->exec($sql);
echo "Table created successfully";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
echo "<br> <br>";
// Skapar garage-tabellen
try {
// sql to create table
$sql = "CREATE TABLE pitches (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
pitch VARCHAR(1),
color 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();
}
echo "<br> <br>";
// Skapar garage-tabellen
try {
// sql to create table
$sql = "CREATE TABLE cost (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
cost VARCHAR(6)
)";
// 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;
?>
</body>
</html>