forked from DaoCloud/php-apache-mysql-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
94 lines (82 loc) · 2.31 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
87
88
89
90
91
92
93
94
<?php
require('DB.php');
$db = new DB();
if ($_POST) {
$db->add($_POST['name'], $_POST['phone']);
}
if ($_GET['delete']) {
$db->remove($_GET['delete']);
}
$contacts = $db->all();
?>
<html>
<head>
<title>PHP-Apache-Mysql-Sample 示例 - DaoCloud</title>
<link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
color: #666;
display: table;
}
.container {
display: table-cell;
text-align: center;
}
.content {
text-align: center;
display: inline-block;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<h1>
PHP-Apache-Mysql-Sample 示例
</h1>
<table class="table">
<caption>通讯录</caption>
<thead>
<tr>
<th>#</th>
<th>姓名</th>
<th>电话</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php foreach ($contacts as $index => $contact) {
?>
<tr>
<th scope="row"> <?php echo $index + 1 ?></th>
<td><?php echo $contact['name'] ?></td>
<td><?php echo $contact['phone'] ?></td>
<td>
<a href="index.php?delete=<?php echo $contact['id'] ?>">删除</a>
</td>
</tr>
<?php
} ?>
</tbody>
</table>
<div class="text-left">
<form method="post">
<div class="form-group">
<label for="name">姓名</label>
<input type="text" name="name" class="form-control" id="name" placeholder="姓名">
</div>
<div class="form-group">
<label for="phone">号码</label>
<input type="text" name="phone" class="form-control" id="phone" placeholder="号码">
</div>
<button type="submit" class="btn btn-success">新增</button>
</form>
</div>
</div>
</div>
</body>
</html>