Källkod
Följande filer och mappar finns under mappen webbserverprogrammering.
Mappar visas till vänster och filer till höger. Klicka på en fil eller mapp för att öppna nedan eller visa dess innehåll.
webbserverprogrammering/exercises/mysql/exercise_3/exercise_3_b/
7 filer
back_button.php
dbconnection.php
index.php
insert_values.php
print_table.php
reset.php
reset_garages_owners.php
dbconnection.php
index.php
insert_values.php
print_table.php
reset.php
reset_garages_owners.php
reset.php
40 lines ASCII Windows (CRLF)
<?php
try {
include("dbconnection.php");
include("back_button.php");
$sql = "DROP TABLE IF EXISTS garages";
$dbconn->exec($sql);
$sql = "DROP TABLE IF EXISTS owners";
$dbconn->exec($sql);
$sql = "DROP TABLE IF EXISTS cars";
$dbconn->exec($sql);
$sql = "CREATE TABLE garages (
garageId INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL
)";
$dbconn->exec($sql);
$sql = "CREATE TABLE owners (
ownerId INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL
)";
$dbconn->exec($sql);
$sql = "CREATE TABLE cars (
carId INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
registrationNmbr VARCHAR(100) NOT NULL,
color VARCHAR(100) NOT NULL,
garage INT NOT NULL,
owner INT NOT NULL
)";
$dbconn->exec($sql);
echo "Tables garages, owners and cars have been reset.";
}
catch (PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
?>