-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
102 lines (96 loc) · 3.24 KB
/
index.php
File metadata and controls
102 lines (96 loc) · 3.24 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
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
<?php
session_start();
if (!isset($_SESSION['user_id'])) {
header('location: signin.php');
exit;
}
$avatar = './assets/sample.png';
?>
<!DOCTYPE html>
<html lang="jp">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ホーム</title>
<link rel="stylesheet" href="./css/common.css" />
<link rel="stylesheet" href="./css/header.css" />
<link rel="stylesheet" href="./css/sidebar.css" />
<link rel="stylesheet" href="./css/main.css" />
</head>
<body>
<div class="header">
<img src="./assets/menu-white.svg" height="40" width="40" />
<div class="header-right">
<form action="" method="get" class="form-example">
<div class="search-box">
<label for="keyword"><img src="./assets/search.svg" height="30" width="30" />
</label>
<input type="text" name="keyword" id="keyword" required />
</div>
</form>
<a href="signout.php">ログアウト</a>
</div>
</div>
<div class="container">
<nav class="sidebar">
<ul>
<li>
<a href="#">
<img src="./assets/home.svg" height="40" width="40" /><strong>ホーム</strong>
</a>
</li>
<li>
<a href="profile.php"><img src="./assets/user.svg" height="40" width="40" />プロフィール</a>
</li>
<li>
<a href="#"><img src="./assets/bell.svg" height="40" width="40" />通知</a>
</li>
<li>
<a href="#"><img src="./assets/heart.svg" height="40" width="40" />いいね</a>
</li>
</ul>
</nav>
<main>
<div class="comment">
<?php
echo "<img class='avatar' src='{$avatar}' height='57' width='57' alt='sample' />"
?>
<form action="./comment.php" method="post" class="comment-form">
<div class="comment-box">
<label for="comment"> </label>
<textarea name="comment" id="keyword" required></textarea>
</div>
<div class="submit-button-wrap">
<button type="submit">投稿する</button>
</div>
</form>
</div>
<div class="timeline">
<ul class="timeline-comments">
<?php
$pdo = require_once 'connect.php';
$sql = 'SELECT comments.user_id, comments.body, users.name FROM comments INNER JOIN users ON comments.user_id = users.user_id';
$statement = $pdo->query($sql);
$comments = $statement->fetchAll();
$reversed = array_reverse($comments);
foreach ($reversed as $comment) {
echo " <li>
<img class='avatar' src='./assets/sample.png' height='57' width='57' alt='sample' />
<div class='timeline-comments-right'>
<strong>{$comment['name']}</strong>
<p>{$comment['body']}</p>
<div class='timeline-comments-reaction'>
<img src='./assets/chat-light.svg' height='20' weight='20' alt='reply' />
<img src='./assets/heart-light.svg' height='20' weight='20' alt='favorite' />
</div>
</div>
</li>";
}
?>
</ul>
</div>
</main>
</div>
</body>
</html>