계층형 게시판 - 5. 글보기
view.php
http://crackh.com/test/board/view.php?idx=1
<?
include "dbconn.php";
$today = time();
$idx = $_GET[idx];
/**************** 덧글 쓰기 처리 ********************************************************/
if($_POST[re] == 'replay'){
$pass=md5($pass);
$sql = "INSERT INTO replay VALUES ('',$idx,'$name','$content','$today','$pass')";
$res = mysql_query($sql);
echo "<script>location.href='./view.php?idx=$idx'</script>";
}
/*****************************************************************************************/
/*******************글내용 가지고오기*******************************/
$sql = mysql_query("SELECT *,FROM_UNIXTIME(wdate) as wdate FROM board WHERE idx = '$idx' ");
$view = mysql_fetch_array($sql);
if($view[header] == 1){
$header = "[알림]";
}else if($view[header] == 2){
$header = "[유머]";
}else if($view[header] == 3){
$header = "[기타]";
}else{
$header ="";
}
/********************************************************************/
$hit = mysql_query("UPDATE board SET hit = hit+1 WHERE idx ='$idx' "); //조회수 증가
$re_sql = mysql_query("SELECT name,contents,FROM_UNIXTIME(wdate) as wdate FROM replay WHERE bbs_no = '$idx' order by idx");
//덧글 가지고 오기
$content =nl2br( $view[content]);//컨텐츠 내용 \n 처리를 html <br>로 처리하여 가지고옴
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang='utf8'>
<!--
* Created on 2012. 7. 23.
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
-->
<head>
<script>
function FormCheck(){
if (!fm.name.value)
{
alert("이름을 입력하세요.");
return false;
}
if (!fm.pass.value)
{
alert("비밀번호를 입력하세요.");
return false;
}
if (!fm.content.value)
{
alert("내용을 입력하세요.");
return false;
}
}
</script>
<title> </title>
</head>
<body>
<form method=post name="fm" onsubmit="return FormCheck()" action='#'>
<input type=hidden name="re" value="replay">
<input type=hidden name="idx" value="<?=$idx?>">
<table width="500" border='1'align='center'>
<tr>
<td>작성자</td><td><?=$view[name]?></td>
</tr>
<tr>
<td>제 목</td><td><?=$header?><?=$view[title]?></td>
</tr>
<tr>
<td>등록일</td><td><?=$view[wdate]?></td>
</tr>
<tr>
<td colspan="2">
<br>
<?=$content?>
<br><br>
</td>
</tr>
<tr>
<td colspan='2' align='right'> <input type="button" value="수정" onclick="location.href='./modify.php?idx=<?=$idx?>'"> <input type="button" value="답글" onclick="location.href='./write.php?type=reply&idx=<?=$idx?>'"></td>
</tr>
<?
while($re = mysql_fetch_array($re_sql)){
?>
<tr>
<td> 아이디 <?=$re[name]?></td>
<td> <?=$re[wdate]?></td>
</tr>
<tr>
<td colspan='2'> <?=$re[contents]?></td>
</tr>
<?}?>
<tr>
<td colspan='2'> 아이디 <input type="text" name="name" id="name"> 비밀번호 <input type="password" name="pass" id="pass"></td>
</tr>
<tr>
<td colspan='2'><textarea rows="2" cols="60" name="content"></textarea></td>
</tr>
<tr>
<td colspan='2' align='right'> <input type="submit" name="submit" value="등록하기"></td>
</tr>
</table>
<br>
<?
include "list.php";
?>
</form>
</body>
</html>
'Coding > PHP' 카테고리의 다른 글
날짜 계산 (0) | 2015.01.30 |
---|---|
하이라트 테스트 (0) | 2015.01.30 |
[PHP] 계층형 게시판 - 4. 리스트 (0) | 2015.01.30 |
[PHP] 계층형 게시판 - 3. 글쓰기 (0) | 2015.01.30 |
[PHP] 계층형 게시판 - 2. 덧글 테이블 구조 (0) | 2015.01.30 |