Skip to content

Commit

Permalink
저자 읽기 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
egoing committed Feb 22, 2018
1 parent 31a0414 commit cfd8202
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
41 changes: 41 additions & 0 deletions author.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
$conn = mysqli_connect(
'localhost',
'root',
'111111',
'opentutorials');
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>WEB</title>
</head>
<body>
<h1><a href="index.php">WEB</a></h1>
<p><a href="index.php">topic</a></p>
<table border="1">
<tr>
<td>id</td><td>name</td><td>profile</td>
<?php
$sql = "SELECT * FROM author";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_array($result)){
$filtered = array(
'id'=>htmlspecialchars($row['id']),
'name'=>htmlspecialchars($row['name']),
'profile'=>htmlspecialchars($row['profile'])
);
?>
<tr>
<td><?=$filtered['id']?></td>
<td><?=$filtered['name']?></td>
<td><?=$filtered['profile']?></td>
</tr>
<?php
}
?>
</tr>
</table>
</body>
</html>
5 changes: 3 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
if(isset($_GET['id'])) {
$filtered_id = mysqli_real_escape_string($conn, $_GET['id']);
$sql = "SELECT * FROM topic LEFT JOIN author ON topic.author_id = author.id WHERE topic.id={$filtered_id}";

$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_array($result);
$article['title'] = htmlspecialchars($row['title']);
Expand All @@ -49,10 +49,11 @@
</head>
<body>
<h1><a href="index.php">WEB</a></h1>
<a href="author.php">author</a>
<ol>
<?=$list?>
</ol>
<a href="create.php">create</a>
<p><a href="create.php">create</a></p>
<?=$update_link?>
<?=$delete_link?>
<h2><?=$article['title']?></h2>
Expand Down

0 comments on commit cfd8202

Please sign in to comment.