-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
60 lines (46 loc) · 1.52 KB
/
create.php
File metadata and controls
60 lines (46 loc) · 1.52 KB
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
//mysql과 연동
$conn = mysqli_connect("localhost","root","try1234","bookrecord");
//query (topic 정보)
$sql="
SELECT * FROM topic
";
//query 실행 후 결과
$result = mysqli_query($conn,$sql);
$list = '';
//while문을 통해 배열을 한행씩 반환
while($row = mysqli_fetch_array($result) ){ //가져올 정보가 없으면 (false) 종료
//책 제목 & 링크 리스트
$escaped_title = htmlspecialchars($row['title']);
$list = $list."<li><a href=\"index.php?id={$row['id']}\">{$escaped_title}</a></li>";
}
$sql = "SELECT * FROM author";
$result = mysqli_query($conn, $sql);
//작가 고를 수 있도록
$select_form = '<select name="author_id">';
while($row = mysqli_fetch_array($result) ){ //가져올 정보가 없으면 (false) 종료
$select_form = $select_form.'<option value="'.$row['id'].'">'.$row['name'].'</option>';
}
$select_form = $select_form.'</select>';
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Book Recording</title>
</head>
<body>
<h1><a href="index.php">독서기록장</a></h1>
<ol>
<?=$list?>
</ol>
<!--글생성-->
<form action = "process_create.php" method="POST">
<p><input type="text" name="title" placeholder="책 제목"></p>
<p><textarea name="description" placeholder="소감을 적어주세요.."></textarea></p>
<!--작가 선택-->
<?=$select_form?>
<p><input type="submit" value="제출"></p>
</form>
</body>
</html>