日期:2014-05-17  浏览次数:20668 次

php 无线级别分类 实现评论回复功能
<?php
header('Content-type:text/html; charset=utf-8');
echo $_SERVER["REMOTE_ADDR"]."<hr/>";  
$sip=substr($_SERVER["REMOTE_ADDR"],10,12);
$eip=200;
if($sip>$eip){
  echo "您的IP值为:<font size='+4' color='red'>".$_SERVER["REMOTE_ADDR"]."</font>在规定的IP段位";
}
else{echo "您的IP值为:<font size='+4' color='red'>".$_SERVER["REMOTE_ADDR"]."不</font>在规定的IP段位";}


echo "<hr /><hr />";


echo "<hr />无线级别分类<br />";
echo "<form action='#' method='post'>";
echo "我的发布:<input type='text' name='content' />";
echo "<input type='submit' value='发布'/>";
echo "</form>";


//************************连接数据库*******************
$link=mysql_connect('localhost','root','') or die('链接失败');
mysql_select_db('test',$link) or die('链接数据库失败!');
@$content=$_REQUEST['content'];
if(isset($content) || $content!=''){
    $sql1="insert into says(c_content,pid,path) values('".$content."','0','0');";
}else{
    echo "<font color='bule' size='+5'>别刷页面行不?有意思吗?</font>";
}
@$oo=mysql_query($sql1);
if($oo){echo "发布成功!<br />";}else{echo "发布失败!<br />";}
$sql="select c_id,c_content,pid,path,concat(path,'-',c_id) as bpath from says order by bpath";
$rows=mysql_query("$sql");
//var_dump($row);
while($res=mysql_fetch_assoc($rows)){
echo "<form  action='#' method='post'>";
$num=count(explode('-',$res['bpath']));
for($i=0;$i<$num*2;$i++){
echo '&nbsp;';
}
    echo "<font color='red'>发布人:</font>".$res['c_id']."<font color='green'>---------------</font>"."<font color='red'>发布内容:</font>".$res['c_content']."<a href='javascript:vode(0)' class='huifu'>回复</a>"."<span></span>"."<hr style='color=\'#F0B\'' /><input type='hidden' name='id' value='".$res['c_id']."' /><input type='hidden' name='path' value='".$res['path']."' /></form>";
}
//***************************回复********************
@$contents=$_REQUEST['contents'];
if(isset($contents) || $contents!=''){
    $bj=$_REQUEST['path']."-".$_REQUEST['id'];
    $sql2="insert into says(c_content,pid,path) values('".$contents."','".$_REQUEST['id']."','".$bj."');";
}
@$aiyao=mysql_query($sql2);
if($aiyao){echo "回复成功!<br />";}else{echo "回复失败!<br />";}


?>
<script src="jquery-1.7.1.min.js"></script>
<script>
  $(".huifu").click(function(){
     var str="<br />回复内容:<textarea id='contents' name='contents'></textarea><input type='submit' value='回复' />";
     $(this).next().html(str);
  })
</script>