-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
122 lines (122 loc) · 2.1 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
// 1. 데이터베이스 서버에 접속
$link = mysql_connect('localhost', 'root', '111111');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
// 2. 데이터베이스 선택
mysql_select_db('opentutorials');
mysql_query("set session character_set_connection=utf8;");
mysql_query("set session character_set_results=utf8;");
mysql_query("set session character_set_client=utf8;");
if (!empty($_GET['id'])) {
$sql = "SELECT * FROM topic WHERE id = " . $_GET['id'];
$result = mysql_query($sql);
$topic = mysql_fetch_assoc($result);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style type="text/css">
body {
font-size: 0.8em;
font-family: dotum;
line-height: 1.6em;
}
body.black {
background-color: black;
color: white;
}
body.black a {
color: white;
}
body.black a:hover {
color: #f60;
}
body.black header {
border-bottom: 1px solid #333;
}
body.black nav {
border-right: 1px solid #333;
}
header {
border-bottom: 1px solid #ccc;
padding: 20px 0;
}
#toolbar {
padding: 10px;
float: right;
}
nav {
float: left;
margin-right: 20px;
min-height: 500px;
border-right: 1px solid #ccc;
}
nav ul {
list-style: none;
padding-left: 0;
padding-right: 20px;
}
article {
float: left;
}
footer {
clear: both;
}
a {
text-decoration: none;
}
a:link, a:visited {
color: #333;
}
a:hover {
color: #f60;
}
h1 {
font-size: 1.4em;
}
.description {
width: 500px;
}
</style>
</head>
<body id="body">
<div>
<header>
<h1>JavaScript</h1>
</header>
<div id="toolbar">
<input type="button" value="black" onclick="document.getElementById('body').className='black'" />
<input type="button" value="white" onclick="document.getElementById('body').className='white'" />
</div>
<nav>
<ul>
<?php
$sql = "select id,title from topic";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
echo "
<li>
<a href=\"?id={$row['id']}\">{$row['title']}</a></li>";
}
?>
</ul>
</nav>
<article>
<?php
if(!empty($topic)){
?>
<h2><?=$topic['title'] ?></h2>
<div class="description">
<?=$topic['description'] ?>
</div>
<?php
}
?>
</article>
</div>
</body>
</html>