ITmembers.net 아카이브 · 2001–2009

질문과 답변

소스에요^^

<?
include 'include/config.inc';
?>
<html>
<head>

<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>
<script language='javaScript'>
function content_check(form)
{
   name=form.name.value.length;
   memo=form.memo.value.length;
   subject=form.subject.value.length;

   if(name == 0) {
      alert("정확한 이름을 입력 하세요");
          form.name.focus();
          return(false);
   }
   if(subject == 0) {
      alert("제목을 입력하세요");
          form.subject.focus();
          return(false);
   }
   if(memo == 0) {
      alert("내용을 입력하세요");
          form.memo.focus();
          return(false);
   }
   if(memo > 8000) {
      alert("길이제한 함다");
          form.memo.focus();
          return(false);
   }
   if(subject > 50) {
      alert("제목은 최대 한글 45자,영문 67자 까지만 허용합니다");
          form.subject.focus();
          return(false);
   }
   return(true);
}
</script>
</head>
<body>
<center>
<?
echo ("
  <form action=insert1.php?parent=$parent&group=$group method=post name=suhoi onSubmit=\"return content_check(this)\">
  ");

if(!$parent)
{
  $subject='';
}
else
{
  $result=mysql_query("select name,subject,memo from myboard where id=$id");
  $row=mysql_fetch_array($result);

  $memo=htmlspecialchars($row[memo]);

  $subject="RE:".$row[subject];
  $name=$row[name];

}
?>
<p>
<table border=0 cellpadding=1 cellspacing=1 bgcolor=#336699>
<tr>
<td width=500 height=20 align=center bgcolor=#336699>
<font color=navy>PHP</font>
</td>
</tr>

<tr></td>
<td height=20 bgcolor=white> 
<table border=0>
<tr>
<td width=60 height=20 align=left bgcolor=#ffffff>이름</td>
<td width=250 height=20 align=left bgcolor=#ffffff>
<input type=text name=name size=20>
</td>
</tr>
<tr>
<td width=60 height=20 align=left bgcolor=#ffffff>이메일</td>
<td width=250 height=20 align=left bgcolor=#ffffff>
<input type=text name=email size=20>
</td>
</tr>
<tr>
<td width=60 height=20 align=left bgcolor=#ffffff>비밀번호</td>
<td width=250 height=20 align=left bgcolor=#ffffff>
<input type=password name=password size=8>(수정 삭제시 반드시 필요)
</td>
</tr>
<tr>
<td width=60 height=20 align=left bgcolor=#ffffff>제목</td>
<td width=250 height=20 align=left bgcolor=#ffffff>
<?
$subject=str_replace(" "," ",$subject);
?>
<input type=text name=subject size=60 value="<? echo $subject; ?>"></p>
</td>
</tr>
<td width=60 height=20 align=left bgcolor=#ffffff>내용</td>
<td width=250 height=20 align=left bgcolor=#ffffff>
<textarea name=memo cols=65 rows=15>
<?
if($name)
{
  echo"\n\n\n:: $name 님 write ::\n";
  echo "$memo\n";
}
?>
</textarea>
</td>
</tr>
<tr>
<td width=60 height=20 align=left bgcolor=#ffffff><p></td>
<td width=250 height=20 align=left bgcolor=#ffffff>
       
<p>
<input type=submit name=submit value="내용 올리기">
         
<input type=reset name=reset value="Cancel">
</form>
<p>
</td>
</tr>
</table>
</td>

</tr>

<tr></td>
<td height=20 bgcolor=white> 
<a href=ex-list.php>[목록보기]</a>
</td>
</tr>
</table>
</center>
<p>
<script>
document.suhoi.name.focus();
</script>
</body>
</html> //글쓰기,수정,답변 소스

<?
include 'include/config.inc';
?>
<html>
<head>

<style>
td {font-size:9pt;}
a:link{font:9pt;color:black;text-decoration:none;font-family:굴림;font-size:9pt;}
a:visited{font:9pt;color:black;text-decoration:none;font-family:굴림;font-size:9pt;}
a:hover{font:9pt;color:black;text-decoration:none;font-family:굴림;font-size:9pt;}
</style>
<script language='javaScript'>
function content_check(form)
{
  search = form.search.value.length;

  if(search == 0) {
    alert("검색어를 입력 하세요");
        form.search.focus();
        return(false);
}
return(true);
}
</script>
</head>
<body>
<center>
<?
//총게시물을 구한다.
$numresults=mysql_query("select id from myboard where del!='y'");
$numrows=mysql_num_rows($numresults);

/*
모든 게시물 수에 next 번호를 매기게 된다 del값이 n인 것만 골라서 next값을 부여한다
디비에서 삭제가 될 경우 부모값이 없어지므로 제자리를 찾지못한다.
그래서 삭제 대신에 y값을 준 것이며, y값도 같이 정렬해서 보여주면서 n인것만 next값을 주는것이다.
*/

function re_see($parentid)
{
  $tablename=myboard;
  static $i=0; //next칼럼의 값을 1부터 주기위해

  $query3="select id,del from $tablename where parent=$parentid order by id desc";
  $result3=mysql_query($query3);

  while($row3=mysql_query($result3))
  {
    if($row3[del]=='n') {
          $i++;
          $query="update $tablename set next=$i where id=$row3[id]";
          mysql_query($query);
    }
        
        //자식메세지 출력 값이 없으면 다시 while 루프수행
        re_see($row3[id]);
  }

}  
re_see(0);

echo ("
<table border=0 cellpadding=1 cellspacing=1>
<tr>
<td width=100 height=20 align=center>
<font color=gray><b>총 게시물 수: $numrows</b></font>
</td>
</td width=350 height=20 align=center>
<font color=gray><b><br>
<form action=search.php method=post onSubmit='return content_check(this)'>
<select name=find>
<option value=name>이름</option>
<option value=subject>제목</option>
<option value=memo>내용</option>
</select>
<input type=text name=search size=10>
<input type=image src=images/search.gif border=0 alt=검색하기>
</form>

</b></font>
</td>
<td width=40 height=20 align=center>
<font color=gray><b><a href=write1.php>글쓰기</a></b></font>
</td>
<td width=50 height=20 align=center>
<font color=gray><b>Admin</b></font>
</td>
</tr>
</table>

<table border=0 cellpadding=1 cellspacing=1 bgcolor=#CA026A>
<tr>
<td width=350 height=20 align=center bgcolor=#CA026A>
<font color=white><b>에피소드-아무얘기나 자유롭게</b></font>
</td>
<td width=50 height=20 align=center bgcolor=#CA026A>
<font color=white>글쓴이</font>
</td>
<td width=80 height=20 align=center bgcolor=#CA026A>
<font color=white>날짜</font>
</td>
<td width=40 height=20 align=center bgcolor=#CA026A>
<font color=white>조회수</font>
</td>
</tr>
");

$limit=10; //페이지 안에 게시물 수
if(!$offset) {
    $offset=0;
}

$result=mysql_query("select * from myboard where del!='y' order by next limit $offset,$limit");
while($row=mysql_fetch_array($result))
{
  echo "<tr>";
  echo "<td height=20 bgcolor=white> ";

  $subject=htmlspecialchars($row[subject]);

  if($row[parent]!=0) //re image
  {
    echo ("  ");
  }
  echo "<a href=read.php?id=$row[id]&offset=$offset>";
  echo "$subject";
  echo "</a>";
  echo "</td>";
  echo "<td align=center height=20 bgcolor=white>";
  echo "<font color=black>";
  $name=htmlspecialchars($row[name]);
  echo "<a href=mailto:$row[email])";
  echo "$name";
  echo "</a>";
  echo "</font>";
  echo "</td>";
  echo "</tr>";
  echo "<td align=center height=20 bgcolor=white>";
  echo "<font color=black>";

  $day=explode(" ",$row[wdate]);
  echo "$day[0]";
  echo "</font>";
  echo "</td>";
  echo "<td align=center height=20 bgcolor=white>";
  echo "<font color=black>";
  echo "$row[see]";
  echo "</font>";
  echo "</td>";
  echo "</tr>";

}

?>
</table>

<table border=0 cellpadding=1 cellspacing=1>
<tr>
<td width=450 height=20 align=center rowspan=4>
<font color=gray>
 
<p>
<b>
<?
if($offset!=0) {
  $prev=$offset-10;
  echo "<a href=\"$PHP_SELF?offset=$prev\">[이전]</a>\n";
}

$pages=ceil($numrows/$limit);

if($numrows%$limit) {
  $pages++;
}

for($i=1;$i<=$pages;$i++) {
$newoffset=$limit*($i-1);
if($offset!=$newoffset) {
echo "<a href=\"$PHP_SELF?offset=$newoffset\">";
}
echo "[$i]";
if (!$offset=$newoffset) {
  echo "</a>";
}

}

if($pages!=1)
{
  $last=($offset/$limit)+1;
  if($pages!=$last)
  {
    $newoffset=$offset+$limit;
        echo "<a href=$PHP_SELF?offset=$newoffset>[다음]</a><p>";
  }
}
?>

</b></font>
</td>
</tr>
</table>

</center>
</body>
</html>//목록 소스입니다

답변 잘 부탁드려요^^

댓글 1