묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
게시판에서 코멘트 관련질문입니다.
2006.05.24 05:18
아래의소스는 제가 사용하는 코멘트부분의소스인데요...
코멘트리스트와 입력부로 나누어져있습니다..
제가 if문으로 코멘트가 없을때 는 else~부분의내용을 나타나게 하고싶은데 잘 안되네요...
<script language="javascript">
function showPassword(ob){
var x,y;
x = (document.body.offsetWidth-200)/2 + document.body.scrollLeft;
y = (document.body.offsetHeight)/2 + document.body.scrollTop;
document.all.divPasswd.style.top = y;
document.all.divPasswd.style.left = x;
document.all.divPasswd.style.display=""
document.pwForm.id.value=ob;
document.pwForm.passwd.focus();
}
function submit_Passwd()
{
var val = document.pwForm.passwd.value;
if (CheckStr(val, " ", "")==0)
{
alert("패스워드를 입력해 주세요");
document.pwForm.passwd.value="";
document.pwForm.passwd.focus();
return;
}
document.pwForm.submit();
}
function CheckStr(strOriginal, strFind, strChange){
var position, strOri_Length;
position = strOriginal.indexOf(strFind);
while (position != -1){
strOriginal = strOriginal.replace(strFind, strChange);
position = strOriginal.indexOf(strFind);
}
strOri_Length = strOriginal.length;
return strOri_Length;
}
</script>
<html>
<head>
<title>『 L E E J I N S O O .net 』 ™</title>
<meta http-equiv=Content-Type content=text/html;>
<link rel=StyleSheet href='style.css' type='text/css'>
</head>
<body bgcolor=#505050>
<?
include "connect.php";
$sql_cmt = " select id,name,comment,ip,DATE_FORMAT(wdate,'%Y-%m-%d %h:%i:%s') as date from $commentname where bid = '+ '+ '$number'";
$result_cmt = mysql_query($sql_cmt,$connect);
while($row_cmt=mysql_fetch_array($result_cmt)) {
$str = $row_cmt[comment];
$comment = strip_tags($str,"");
$str = $row_cmt[name];
$name = strip_tags($str,"");
//커멘트 리스트
?>
<?
if(mysql_num_rows($row_cmt > 0)
echo"
<table width=100% border=0 align=center cellpadding=0 cellspacing=0>
<tr bgcolor=#505050 >
<td >
<table width=100%>
<tr >
<td width=100% background='./images/kor_comment_bak.gif' height=32>
<font color=#609060><b><?=$name?></b></font>
<font color=#999999><span style="font-size:11px;"><?=$row_cmt[date]?></span></font>
<a href="javascript:showPassword(<?=$row_cmt[id]?>);"><img src='./images/kor_comment_del.gif' border=0></a></td>
</tr>
</table>
<table width=100%>
<tr>
<td>
<font color=#c2c2c2><?=nl2br($comment)?></font></td>
</tr>
</table><br>
</td>
</tr>
</table>";
}
else {
echo"
<table width=100% border=0 align=center cellpadding=0 cellspacing=0>
<tr bgcolor=#505050 >
<td >
<table width=100%>
<tr >
<td width=100% background='./images/kor_comment_bak.gif' height=32 align=center>
현재 작성된 의견 (코멘트)이 없습니다.</td>
</tr>
</table>
<br>
</td>
</tr>
</table>";
}
?>
<?
//-- END
}
// 코멘트 입력
?>
<br>
<table width=90% border=0 align=center cellpadding=0 cellspacing=0>
<tr>
<td bgcolor=#505050>
<table width=95% cellpadding=0 cellspacing=0>
<form name=comment_insert method=post action='comment_ok.php'>
<input type=hidden name=bid value='<?=$number?>'>
<tr>
<td><img src="./images/kor_comment_title.gif" border=0></td>
</tr>
<tr>
<td><textarea name=comment rows=7 class=textarea2></textarea></td>
</tr>
</table><br>
<table width=95% cellpadding=0 cellspacing=0>
<tr>
<td height="27" align=right>
이름 : <input type=text name=name size=10 class=input3 align=middle>
비밀번호 : <input type=password name=passwd size=10 class=input3 align=middle>
<input type=image value="등 록" src=./images/kor_view_save.gif border=0 align=middle>
</td>
</tr>
</table>
</form>
</table>
</td>
</tr>
</table>
<!-- 패스워드 창 -->
<div id="divPasswd" style="display:none;position:absolute;">
<form name=pwForm method=post action='comment_del.php'>
<table border="1" bordercolor="#777777"><tr><td>
<table width=200 cellpadding=0 cellspacing=0>
<tr>
<td bgcolor="#505050" height=32 align="left" style="padding-left:30;">
<font color=#609060>비밀번호</font><font color=#c2c2c2>를 입력하세요.</font>
<img src="./images/kor_comment_del.gif" style="cursor:hand" onClick="javascript:document.all.divPasswd.style.display='none';" WIDTH="10" HEIGHT="10">
</td>
</tr>
<tr>
<td bgcolor="#505050" style="padding-left:10;padding-right:10;padding-bottom:10;padding-top:5">
<input name="passwd" type="password" class=input2>
<input type="hidden" name="bid"size="10" value="<?=$number?>">
<input type="hidden" name="id" size="10" value="">
<img src="./images/kor_comment_del_ok.gif" style="cursor:hand" align="absmiddle" onClick="submit_Passwd(this);" WIDTH="30" HEIGHT="20">
</td>
</tr>
</table>
</td></tr></table>
</form>
</div><!-- 패스워드 창 -->
코멘트리스트와 입력부로 나누어져있습니다..
제가 if문으로 코멘트가 없을때 는 else~부분의내용을 나타나게 하고싶은데 잘 안되네요...
<script language="javascript">
function showPassword(ob){
var x,y;
x = (document.body.offsetWidth-200)/2 + document.body.scrollLeft;
y = (document.body.offsetHeight)/2 + document.body.scrollTop;
document.all.divPasswd.style.top = y;
document.all.divPasswd.style.left = x;
document.all.divPasswd.style.display=""
document.pwForm.id.value=ob;
document.pwForm.passwd.focus();
}
function submit_Passwd()
{
var val = document.pwForm.passwd.value;
if (CheckStr(val, " ", "")==0)
{
alert("패스워드를 입력해 주세요");
document.pwForm.passwd.value="";
document.pwForm.passwd.focus();
return;
}
document.pwForm.submit();
}
function CheckStr(strOriginal, strFind, strChange){
var position, strOri_Length;
position = strOriginal.indexOf(strFind);
while (position != -1){
strOriginal = strOriginal.replace(strFind, strChange);
position = strOriginal.indexOf(strFind);
}
strOri_Length = strOriginal.length;
return strOri_Length;
}
</script>
<html>
<head>
<title>『 L E E J I N S O O .net 』 ™</title>
<meta http-equiv=Content-Type content=text/html;>
<link rel=StyleSheet href='style.css' type='text/css'>
</head>
<body bgcolor=#505050>
<?
include "connect.php";
$sql_cmt = " select id,name,comment,ip,DATE_FORMAT(wdate,'%Y-%m-%d %h:%i:%s') as date from $commentname where bid = '+ '+ '$number'";
$result_cmt = mysql_query($sql_cmt,$connect);
while($row_cmt=mysql_fetch_array($result_cmt)) {
$str = $row_cmt[comment];
$comment = strip_tags($str,"");
$str = $row_cmt[name];
$name = strip_tags($str,"");
//커멘트 리스트
?>
<?
if(mysql_num_rows($row_cmt > 0)
echo"
<table width=100% border=0 align=center cellpadding=0 cellspacing=0>
<tr bgcolor=#505050 >
<td >
<table width=100%>
<tr >
<td width=100% background='./images/kor_comment_bak.gif' height=32>
<font color=#609060><b><?=$name?></b></font>
<font color=#999999><span style="font-size:11px;"><?=$row_cmt[date]?></span></font>
<a href="javascript:showPassword(<?=$row_cmt[id]?>);"><img src='./images/kor_comment_del.gif' border=0></a></td>
</tr>
</table>
<table width=100%>
<tr>
<td>
<font color=#c2c2c2><?=nl2br($comment)?></font></td>
</tr>
</table><br>
</td>
</tr>
</table>";
}
else {
echo"
<table width=100% border=0 align=center cellpadding=0 cellspacing=0>
<tr bgcolor=#505050 >
<td >
<table width=100%>
<tr >
<td width=100% background='./images/kor_comment_bak.gif' height=32 align=center>
현재 작성된 의견 (코멘트)이 없습니다.</td>
</tr>
</table>
<br>
</td>
</tr>
</table>";
}
?>
<?
//-- END
}
// 코멘트 입력
?>
<br>
<table width=90% border=0 align=center cellpadding=0 cellspacing=0>
<tr>
<td bgcolor=#505050>
<table width=95% cellpadding=0 cellspacing=0>
<form name=comment_insert method=post action='comment_ok.php'>
<input type=hidden name=bid value='<?=$number?>'>
<tr>
<td><img src="./images/kor_comment_title.gif" border=0></td>
</tr>
<tr>
<td><textarea name=comment rows=7 class=textarea2></textarea></td>
</tr>
</table><br>
<table width=95% cellpadding=0 cellspacing=0>
<tr>
<td height="27" align=right>
이름 : <input type=text name=name size=10 class=input3 align=middle>
비밀번호 : <input type=password name=passwd size=10 class=input3 align=middle>
<input type=image value="등 록" src=./images/kor_view_save.gif border=0 align=middle>
</td>
</tr>
</table>
</form>
</table>
</td>
</tr>
</table>
<!-- 패스워드 창 -->
<div id="divPasswd" style="display:none;position:absolute;">
<form name=pwForm method=post action='comment_del.php'>
<table border="1" bordercolor="#777777"><tr><td>
<table width=200 cellpadding=0 cellspacing=0>
<tr>
<td bgcolor="#505050" height=32 align="left" style="padding-left:30;">
<font color=#609060>비밀번호</font><font color=#c2c2c2>를 입력하세요.</font>
<img src="./images/kor_comment_del.gif" style="cursor:hand" onClick="javascript:document.all.divPasswd.style.display='none';" WIDTH="10" HEIGHT="10">
</td>
</tr>
<tr>
<td bgcolor="#505050" style="padding-left:10;padding-right:10;padding-bottom:10;padding-top:5">
<input name="passwd" type="password" class=input2>
<input type="hidden" name="bid"size="10" value="<?=$number?>">
<input type="hidden" name="id" size="10" value="">
<img src="./images/kor_comment_del_ok.gif" style="cursor:hand" align="absmiddle" onClick="submit_Passwd(this);" WIDTH="30" HEIGHT="20">
</td>
</tr>
</table>
</td></tr></table>
</form>
</div><!-- 패스워드 창 -->