Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/exercises/ovn_db/ovn_db3/
db/
garage.php
show_tables.php
show_tables_b.php
show_tables_c.php
show_tables_e.php
garage.php
56 lines UTF-8 Windows (CRLF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Garage</title>
</head>
<body>
<?php
require __DIR__ . '/../../../dbconnect.php';
?>
<form action="db/add_car.php" method="post">
<h2>Lägg till en bil</h2>
<label for="regnr">Registreringsnummer*:</label>
<input type="text" id="regnr" name="regnr">
<label for="color">Färg*:</label>
<input type="text" id="color" name="color">
<label for="garage">Garage*:</label>
<select name="garage" id="garage">
<?php
$stmt = $dbconn->prepare("SELECT * FROM garage");
$stmt->execute();
while ($res = $stmt->fetch(PDO::FETCH_ASSOC)) {
?>
<option value="<?php echo $res["garageid"]; ?>"><?php echo $res["name"]; ?></option>
<?php
}
?>
</select>
<label for="owner">Ägare*:</label>
<select name="owner" id="owner">
<?php
$stmt = $dbconn->prepare("SELECT * FROM owner");
$stmt->execute();
while ($res = $stmt->fetch(PDO::FETCH_ASSOC)) {
?>
<option value="<?php echo $res["ownerid"]; ?>"><?php echo $res["name"]; ?></option>
<?php
}
?>
</select>
* = obligatoriskt
<button type="submit">Lägg till</button>
</form>
</body>
</html>