generated from teknasyon-bootcamp/homework4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
168 lines (139 loc) · 5.42 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php require "post.class.php"; ?>
<!DOCTYPE html>
<html lang="en">
<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>Posts</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<style>
.post-box{
width: 100%;
height: 400px;
background-color: white;
border-radius: 5px;
position: relative;
}
.post-box h1{
text-align: center;
}
.post-box-inner p{
padding: 2em;
}
.post-box-inner a{
text-decoration: none;
}
.post-author{
position: absolute;
bottom:5%;
left: 3%;
font-weight: bold;
}
.post-read{
position: absolute;
bottom: 5%;
right:5%;
}
</style>
</head>
<body style = "background-color:rgb(240, 240, 240)">
<div class = "container">
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-light bg-primary mb-5" >
<a class="navbar-brand" href="http://localhost/homework4-grup-7/index.php" style="color: white; font-weight:bold">Homework4-grup-7</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" style="color: white;" href="http://localhost/homework4-grup-7/index.php">Index <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" style="color: white;" href="http://localhost/homework4-grup-7/manage.php">Manage<span class="sr-only">(current)</span></a>
</li>
</ul>
</div>
</nav>
<!-- Navbar -->
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">id</th>
<th scope="col">Yazar</th>
<th scope="col">Başlık</th>
<th scope="col">Oluşturulma Tarihi</th>
</tr>
</thead>
<tbody>
<?php
if(isset($_GET['post'])){
$id = $_GET['post'];
$postObj = new Post(new DB());
$post = $postObj->postDetail($id);
foreach($post as $post_val){
echo "<tr>" . PHP_EOL;
echo "<th scope ='row'>$post_val[id]</th>" . PHP_EOL;
echo "<td>$post_val[author]</td>" . PHP_EOL;
echo "<td><a href='http://localhost/homework4-grup7/$post_val[post_header].php'> $post_val[post_header]</a></td>" . PHP_EOL;
echo "<td>$post_val[post_created]</td>" . PHP_EOL;
echo "</tr> " . PHP_EOL;
}
} else {
$postObj = new Post(new DB());
$posts = $postObj->postLists();
foreach($posts as $post){
echo "<tr>" . PHP_EOL;
echo "<th scope ='row'>$post[id]</th>" . PHP_EOL;
echo "<td>$post[author]</td>" . PHP_EOL;
echo "<td><a href='http://localhost/homework4-grup7/$post[post_header].php'> $post[post_header]</a></td>" . PHP_EOL;
echo "<td>$post[post_created]</td>" . PHP_EOL;
echo "</tr> " . PHP_EOL;
}
}
?>
</tbody>
</table>
<form action="index.php" method="GET">
<div class="form-group">
<label for="search-post">Post ara</label>
<input type="text" name = "post" class="form-control" placeholder="id değeri giriniz">
</div>
<button class="btn btn-primary" type="submit">Ara</button>
</form>
<div class="container p-0 mt-5">
<?php
if(isset($_GET['post'])){
foreach($post as $post_val){
echo "<div class ='post-box mt-5'>";
echo "<div class = 'post-box-inner'>";
echo "<h1> <a href='http://localhost/homework4-grup7/$post_val[post_header].php'>$post_val[post_header]</a></h1>";
echo "<p>";
echo substr($post_val['post_detail'], 0 ,1500);
echo "...</p>";
echo "</div>";
echo "<div class ='post-author'>Yazar: $post_val[author]</div>";
echo "<div class ='post-read'><a href='http://localhost/homework4-grup7/$post_val[post_header].php'>Devamını okumak için tıklayın</a></div>";
echo "</div>";
}
}else{
foreach($posts as $post){
echo "<div class ='post-box mt-5'>";
echo "<div class = 'post-box-inner'>";
echo "<h1> <a href='http://localhost/homework4-grup7/$post[post_header].php'>$post[post_header]</a></h1>";
echo "<p>";
echo substr($post['post_detail'], 0 ,1500);
echo "...</p>";
echo "</div>";
echo "<div class ='post-author'>Yazar: $post[author]</div>";
echo "<div class ='post-read'><a href='http://localhost/homework4-grup7/$post[post_header].php'>Devamını okumak için tıklayın</a></div>";
echo "</div>";
}
}
?>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
</body>
</html>