forked from MarkNBroadhead/CreatureCreator
/
AttributeEdit.php
60 lines (57 loc) · 1.82 KB
/
AttributeEdit.php
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
57
58
59
60
<?php
use BattleChores\domain\creature\CreatureAttributeGateway;
use BattleChores\domain\creature\CreatureAttributeTypeGateway;
include 'config.php';
include 'php_classes/setup.php';
try {
$database = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
print 'Connection failed: ' . $e->getMessage();
}
$printHtml = new \BattleChores\PrintHtml();
echo $printHtml->head("Attribute Type Edit");
?>
<body>
<main>
<h1>Attribute Edit</h1>
<div>
<h2>Add new attribute</h2>
<form method="post" action="AttributeAdd.php">
<select name="Type">
<?php
$creatureAttributeTypeGateway = new CreatureAttributeTypeGateway($database);
$results = $creatureAttributeTypeGateway->selectAll();
foreach ($results as $type) {
print '<option value="' . $type['id'] . '">' . $type['name'] . '</option>';
}
?>
</select><br />
<input type="text" name="Name">
<input type="submit" value="Create">
<input type="reset" value="Restart">
</form>
</div>
<div>
<h2>Attributes</h2>
<table>
<tr>
<td>id</td>
<td>name</td>
<td>attribute type</td>
</tr>
<?php
$attributegateway = new CreatureAttributeGateway($database);
$attributes = $attributegateway->selectAll();
foreach ($attributes as $attribute) {
print "<tr>";
print "<td>" . $attribute['id'] . "</td>";
print "<td>" . $attribute['name'] . "</td>";
print "<td>" . $attribute['type_name'] . "</td>";
print "</tr>";
}
?>
</table>
</div>
</main>
</body>
</html>