forked from mfk1337/sqltest1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
86 lines (63 loc) · 1.85 KB
/
index.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?
include('includes/config.php');
//$db->where ('town', 'København');
?>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body>
<h1>joshcam/PHP-MySQLi-Database-Class Test</h1>
<?
if($_GET['rediger'])
{
$db->where ("id", $_GET['ID']);
$row = $db->getOne("contacts");
?>
<form method="post" class="col-md-3" action="actions/gem.php?ID=<? echo $row['id'];?>">
Navn:<br/>
<input type="text" name="name" class="form-control" value="<? echo $row['name'];?>" required="" />
Tlf:<br/>
<input type="text" name="phone" class="form-control" value="<? echo $row['phone'];?>" required="" />
By:<br/>
<input type="text" name="town" class="form-control" value="<? echo $row['town'];?>" required="" />
<button class="btn btn-success" type="submit">Gem</button>
</form>
<?
}else{
?>
<form method="post" class="col-md-3" action="actions/add.php">
Navn:<br/>
<input type="text" name="name" class="form-control" required="" />
Tlf:<br/>
<input type="text" name="phone" class="form-control" required="" />
By:<br/>
<input type="text" name="town" class="form-control" required="" />
<button class="btn btn-success" type="submit">Tilføj</button>
</form>
<?
}
$db->orderBy("name","asc");
$users = $db->get('contacts');
?>
<table class="table">
<tr>
<td>Navn</td>
<td>Tlf</td>
<td>By</td>
<td>Ret/slet</td>
</tr>
<?
foreach ($users as $row)
{
?>
<tr>
<td><? echo $row['name']; ?></td>
<td><? echo $row['phone']; ?></td>
<td><? echo $row['town']; ?></td>
<td><a href="?rediger=true&ID=<? echo $row['id'];?>" class="btn btn-default">Rediger</a> <a href="actions/slet.php?ID=<? echo $row['id'];?>" class="btn btn-danger">Slet</a></td>
</tr>
<?
}
?>
</table>
</body>