PHP질문드립니다. > 자유게시판

자유게시판

PHP질문드립니다. 정보

PHP질문드립니다.

본문




여기서 게시글과 코맨트가 있는데
게시글 A,B,C가 있다면
위에꺼는 A에서 쓴코멘트가 B에서보 보이는데
A에서 쓴 코멘트 B에서 쓴 코멘트 따로 따로 놓을 수는 없을까요??
read.php 라는 데에다가 만들었는데 따로 php만들지 않고 read밑에다가 만들었어요.


http://static.se2.naver.com/static/img/bg_b1.png) repeat;_background:none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://static.se2.naver.com/static/img/bg_b1.png',sizingMethod='scale');color:#888888;">
-Read.php

<HTML>
<head>
<title> 게시판보기 </title>
<style>
<!--
td {font-size: 9pt;}
A:link {font: 9pt; color: black; text-decoration: none;
font-family: 굴림; font-size: 9pt;}
A:visited {text-decoration: none; color: black; font-size: 9pt;}
A:hover {text-decoration: underline; color: black;
font-size: 9pt;}
-->
</style>
</head>

<body topmargin=0 leftmargin=0 text=#464646>
<center>
<br>
<?
//데이터베이스 연결하기
include "db_info.php";

//아이디값을 GET으로 불러온다.
//쿼리의 문제가 생길때는 query ="어쩌구저쩌구" or die mysql_error(); 로 sql로 오류를 잡는다.
$id = $_GET['id'];
$query = "UPDATE board  SET view = view+1 WHERE id=$id";

//조회수 증가
$result = mysql_query($query, $conn);

$query = "SELECT * FROM board  WHERE id=$id";

//글 정보 가져오기
$result = mysql_query($query , $conn);
$row = mysql_fetch_array($result);
?>
<!-- 글보기 -->
<table width=580 border=0 cellpadding=2 cellspacing=1
bgcolor=#777777>
<tr>
<td height=20 colspan=4 align=center bgcolor=#999999>
<font color=white><b><?=$row[title]?></b></font>
</td>
</tr>
<tr>
<td width="50" height="20" align=center bgcolor=#EEEEEE>글쓴이</td>
<td width="240" bgcolor=white><?=$row[name]?></td>
<td  wiFth="50" height="20" align=center bgcolor=#EEEEEE>이메일</td>
<td  width="240" bgcolor=white><?=$row[email]?></td>
</tr>
<td width="50" height="20" align=center bgcolor=#EEEEEE>
날   짜</td>
<td width="240" bgcolor=white><?=$row[wdate]?></td>
<td  width="50" height="20" align=center bgcolor=#EEEEEE>조회수</td>
<td  width="240" bgcolor=white><?=$row[view]?></td>
</tr>
<tr>
<td bgcolor=white colspan="4">
<font color="black">
<pre><?=$row[content]?></pre>
</font>
</td>
</tr>
<!-- 기타 버튼 들-->
<tr>
<td colspan="4" bgcolor=#999999>
<table width=100%>
<tr>
<td width="200" align=left height="20">
<a href=list.php?no=<?=$no?>><font color="white">
목록보기</font></a>
<a href=write.php><font color="white">
글쓰기</font></a>
<a href=edit.php?id=<?=$id?>><font color="white">
수정</font></a>
<a href=predel.php?id=<?=$id?>>
<font color="white">삭제</font></a>
</td>
<!-- 기타 버튼 끝-->
<!-- 이전 다음 표시 -->
<td align=right>
<?
//현재 글 보다 id 값이 큰 글 중 가장 작은 것을 가져온다
// 즉 바로 이전 글
$query = mysql_query("SELECT id FROM board WHERE id > $id LIMIT 1",
$conn);
$prev_id = mysql_fetch_array($query);

//이전 글 이 있는 경우
if ($prev_id[id]) 
{
echo"<a href=read.php?id=$prev_id[id]>
<font color=white>이전</font></a>";
}
else
{
echo "[이전]";
}

$query = mysql_query("SELECT id FROM board WHERE id < $id
ORDER BY id DESC LIMIT 1", $conn);
$next_id = mysql_fetch_array($query);

//다음 글 이 있는 경우
if ($next_id[id])
{
echo "<a href=read.php?id=$next_id[id]>
<font color=white>다음</font></a>";
}
else
{
echo"[다음]";
}
?>
</td>
</tr>
</table>
</b> </font>
</td>
</tr>
</table>
</center>
</body>
<br>

<?
//데이터베이스 소환!!
$conn = mysql_connect ("localhost", "root", "4745qkr");
mysql_select_db ("talk", $conn);
mysql_query ("set names euckr");

//아래 셀렉트문의 *을 변경해야함. 
$query = "SELECT * FROM talk ORDER BY id";
$result = mysql_query($query, $conn); 
$total = mysql_affected_rows();

//페이지사이즈
$page_size="20";
?>

<!--댓글 폼을 생성합니다-->
<FORM Name="comm" ACTION="com_insert.php" METHOD="POST" Onsubmit="commformcheck()">
<!--인풋 타입 속성:히든값 name은 가져올 변수값 value는 불러올 변수값 php값은 폼에서 안되니 <?=$변수?>으로 만든다-->
<input type="hidden" name="id" value="<?=$id?>">
<TABLE width="582" border="0" cellpadding="2" cellspacing="1" bgcolor=#EEEEEE align="center">
<TD height="20" colspan="4" align="center" bgcolor=#999999><FONT color=white>댓글</TD></FONT>
<TR>
<TD width="500" height="20" align=center bgcolor=white>이름<input type="text" name="name"></TD>
<TD width="500" height="20" align=center bgcolor=white>비밀번호<input type="password" name="pass"></TD>
<!--<TD align=center bgcolor=white>-->
</TR>
<TR>
<TD COLSPAN="4">
<TEXTAREA NAME="content" cols="79"  rows="1" style="max-heigh:100pt; min-height:100pt;
resize:none" ></TEXTAREA>
</TR>
<TR>
<TD COLSPAN="4" align=right><INPUT TYPE="SUBMIT" VALUE="확인"></TD>
<input type="hidden" name="id" value='<?=$_GET[id]?>'>
</TR>
</TABLE>
</FORM>
<BR>
<?
for($I=$_GET[no] ; $i < $_GET[no]+$page_size; $i++){

if ($i < $total)
{
$row = mysql_data_seek($result, $i);
$row = mysql_fetch_array($result);
?>
<TABLE width="582" border="0" cellpadding="2" cellspacing="1" bgcolor=#EEEEEE align="center">
<TR>
<!-- 코멘트 값중에 wdate를 제외하도 Ymd나오게해야함 -->
<TD width="500" height="20" align=left bgcolor=white>번호: <?=$row[id]?></TD>
<TD width="500" height="20" align=left bgcolor=white><?=$row[name]?></TD>
<TD width="500" height="20" align=center bgcolor=white>(<?=$date = date ("Y m,d)")?></TD>
<TD width="500" height="20" align=r bgcolor=white><a href="cdel.php? id=<?=$row[id]?>">삭제</a></TD>
</TR>
<TR>
<TD COLSPAN="4"><?=$row[content]?></TD>
</TR>
<return false;>
</TABLE>
<?
} //enc if
} //end for
?>
</html>

http://static.se2.naver.com/static/img/bg_b1.png) repeat;_background:none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://static.se2.naver.com/static/img/bg_b1.png',sizingMethod='scale');color:#888888;">
-com_insert.php

<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<?
$_POST[name] = trim(strip_tags($_POST[name]));


//데이터를 가지고 온다.
$conn = mysql_connect("localhost", "root", "4745qkr");
mysql_select_db("talk", $conn);
//쿼리를 보내겠지 한글이 나오도록..
mysql_query("set names euckr");

$query = "INSERT INTO talk (name, pass, content)";
$query .= "VALUES ('$_POST[name]', '$_POST[pass]', '$_POST[content]')";
$result = mysql_query($query, $conn) or ErrorMessage ('댓글을 저장하는데 실패했습니다.');
?>
<Script>
alert("글이 등록되었습니다.");
location.href="read.php?id=<?=$id?>";
</Script>
// <input type="hidden" name="id" value="<?=$id?>">

추천
0

댓글 0개

전체 199,675 |RSS
자유게시판 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT