Read Replication
undefined undefined
Read Replication

예제

db.php

1
2
3
<?php
$write = mysqli_connect('', '', '', 'o2');
$read = mysqli_connect('', '', '', 'o2');

rds.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
<!DOCTYPE>
<html>
<head><meta charset="utf-8"></head>
<body>
<form action="rds_receiver.php" method="post">
<p>
제목 :
<input type="text" name="title">
</p>
<p>
본문 :
<textarea name="description">
</textarea>
</p>
<p><input type="submit"></p>
</form>
<ul>
<?php
include('db.php');
$result = mysqli_query($read, "SELECT * FROM topic");
while($row = mysqli_fetch_assoc($result)){
$title = mysqli_real_escape_string($read, $row['title']);
print("<li>{$title}</li>");
}
?>
</ul>
</body>
</html>

rds_receiver.php

1
2
3
4
5
6
7
8
<?php
include('db.php');
$title = mysqli_real_escape_string($write, $_POST['title']);
$description = mysqli_real_escape_string($write, $_POST['description']);
$sql = "INSERT INTO topic (title, description, author, created) VALUES('{$title}', '{$description}', 'egoing', NOW())";
mysqli_query($write, $sql);
header('Location: rds.php');
?>
질문하기
추가 자료
no files uploaded

추가 자료가 없습니다

여기서 새로운 학습 자료를 확인하세요!
선생님이 추가한 자료들을 바로 확인할 수 있어요.