-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpost.php
90 lines (84 loc) · 4.27 KB
/
post.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
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>POST</title>
</head>
<body>
<div>
<h1 style="text-align: center;">Webboard Shabu</h1>
<?php include "nav.php" ?>
<div class="row mt-4">
<div class="col-lg-3 col-md-2 col-sm-1"></div>
<div class="col-lg-6 col-md-8 col-sm-10">
<?php
$conn=new PDO("mysql:host=localhost;dbname=webboard;charset=utf8","root","");
$sql="SELECT post.title,post.content,post.post_date,user.login FROM post INNER JOIN user ON
(post.user_id=user.id) WHERE post.id=$_GET[id]";
$result=$conn->query($sql);
while($row=$result->fetch()){
echo "<div class='card border-primary mt-3'>";
echo "<div class='card-header bg-primary text-white'>
$row[0]
</div>";
echo "<div class='card-body'>
$row[1]
<br><br>$row[3] - $row[2]
</div>";
echo "</div>";
};
$sql1="SELECT comment.content,comment.post_date,user.login comment FROM comment INNER JOIN user ON
(comment.user_id=user.id) WHERE comment.post_id=$_GET[id]";
$result=$conn->query($sql1);
$i=1;
while($row=$result->fetch()){
echo "<div class='card border-info mt-3'>";
echo "<div class='card-header bg-info text-white'>
ความเห็นที่ $i
</div>";
echo "<div class='card-body'>
$row[0]
<br><br>$row[2] - $row[1]
</div>";
echo "</div>";
$i++;
};
$conn=null;
?>
<?php if(isset($_SESSION['id'])){ ?>
<div class="card border-success mt-3">
<div class="card-header bg-success text-white">แสดงความเห็น</div>
<div class="card-body">
<form action="post_save.php" method="post">
<input type="hidden" name="post_id" value="<?= $_GET['id']; ?>">
<div class="row mb-3 justify-content-center">
<div class="col-lg-10">
<textarea name="comment" id="" rows="8" class="form-control" required></textarea>
</div>
</div>
<div class="row">
<div class="col-lg-12 d-flex justify-content-center">
<button type="submit" class="btn btn-success btn-sm text-white">
<i class="bi bi-box-arrow-up-right"></i> ส่งข้อความ
</button>
<button type="reset" class="btn btn-danger btn-sm ms-2"><i class="bi bi-x-square"></i>ยกเลิก</button>
</div>
</div>
</form>
</div>
</div>
<?php }?>
<br>
</div>
<div class="col-lg-3 col-md-2 col-sm-1"></div>
</div>
</div>
</body>
</html>