** read.php
<?php
session_start();
if(!isset($_SESSION['username'])) {
echo "<script>alert('비회원입니다!');</script>";
echo "<script>window.history.back() </script>";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<style>
.read_table {
border: 1px solid #444444;
margin-top: 30px;
}
.read_title {
height: 45px;
font-size: 23.5px;
text-align: center;
background-color: #3C3C3C;
color: white;
width: 1000px;
}
.read_id {
text-align: center;
background-color: #EEEEEE;
width: 30px;
height: 33px;
}
.read_id2 {
background-color: white;
width: 60px;
height: 33px;
padding-left: 10px;
}
.read_hit {
background-color: #EEEEEE;
width: 30px;
text-align: center;
height: 33px;
}
.read_hit2 {
background-color: white;
width: 60px;
height: 33px;
padding-left: 10px;
}
.read_content {
padding: 20px;
border-top: 1px solid #444444;
height: 500px;
}
</style>
</head>
<body>
<?php
$connect = mysqli_connect('localhost', 'root', 'mysql', 'board');
$idx = $_GET['idx']; // GET 방식
session_start();
// 조회수 기능
$hit="update board set hit=hit+1 where idx=$idx";
$connect->query($hit);
$query = "select name, title, content, udate, hit, liked from board where idx = $idx";
$result = $connect->query($query);
$rows = mysqli_fetch_assoc($result);
?>
<table class="read_table" align=center>
<tr>
<td colspan="4" class="read_title"><?php echo $rows['title'] ?></td>
</tr>
<tr>
<td class="read_id">작성자</td>
<td class="read_id2"><?php echo $rows['name'] ?></td>
<td class="read_hit">조회수</td>
<td class="read_hit2"><?php echo $rows['hit'] ?></td>
</tr>
<tr>
<td colspan="4" class="read_content" valign="top">
<?php echo $rows['content'] ?></td>
</tr>
</table>
</body>
</html>
** 구현

클릭 → 게시글 보기 & 조회수+1

'Web Hacking Study > Web Page 만들기' 카테고리의 다른 글
| 게시판 페이지 개발 (게시글 삭제 기능) (0) | 2022.05.30 |
|---|---|
| 게시판 페이지 개발 (게시글 수정 기능) (0) | 2022.05.29 |
| 게시판 페이지 개발 (게시글 작성 기능) (0) | 2022.05.18 |
| 게시판 페이지 개발 (게시글 리스트 출력) (0) | 2022.05.18 |
| 게시판 페이지 개발 (DB 만들기) (0) | 2022.05.18 |
댓글