请各位朋友们帮我写一写论坛发表回帖的实现过程的(PHP+Mysql)代码? 

解决方案 »

  1.   

    1、页面显示相应主题及主题所回复的帖子,从数据表A,B中分别获取
    2、新增回帖时写入回帖的表,B表;刷新页面
      

  2.   

    BiaoDan_HuiTie.php
    <TABLE class=bordercolor style="MARGIN-TOP: 1px" cellSpacing=1 cellPadding=8 width="100%" border=0>
    <TBODY>
    <TR>
    <TD align="center"  class=Tdbg_BaiSe>
    <b>Re:<?php ZT_Title($ZT_Id) ?></b>
    </td>
    </tr>
    <tr>
    <td valign="top"  class=Tdbg_BaiSe>
    <textarea cols="80" id="I_HFFB_Text" rows="10"></textarea>
    </td>
    </tr>
    <tr>
    <td  class=Tdbg_BaiSe>
    <input type="button" value="提 交"  onclick="javaScript:Fun_Sure_HFFB(); "/>
    </td>
    </tr>
    </table>
    ajax.js
    function Fun_Sure_HFFB(){//发表回复验证
    if(DengLu_Type==0){//还没有登录时,不允许发表帖子
    alert("您还没有登录,请先登录!")
    }else{//已经登录了,允许发表帖子
    HF_Text=CKEDITOR.instances.I_HFFB_Text.getData();
    if(HF_Text==""){
    alert("请输入内容!!!")
    CKEDITOR.instances.I_HFFB_Text.focus();
    }else{
    //document.all("I_HFFB_Text").value=""//帖子已经成功提交并写入了数据库,输入框中的内容已经不再需要了.清空
    SendMsg("加载发表回复表单","Td_ShowFBTZ");
    if(CKEDITOR.instances['I_HFFB_Text']){ //判断 I_ZTText 是否已经被绑定
    CKEDITOR.remove(CKEDITOR.instances['I_HFFB_Text']); //如果绑定了就解绑定
    }  
    CKEDITOR.replace( 'I_HFFB_Text',{toolbar:[
      ['Styles','Format','Font','FontSize','Undo','Redo','Find','Cut','Copy','Paste','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],'/',
      ['NumberedList', 'BulletedList','Outdent','Indent','Subscript','Superscript','TextColor','BGColor','Bold', 'Italic','Underline','Strike','RemoveFormat'],
      ['Blockquote','Link', 'Anchor','Image','Flash','HorizontalRule','Smiley','SpecialChar','PageBreak']]});
    tBack_Num="把回复内容写入数据库";//只执行写入操作,不用返回值
    HF_Text=ZhuanHuanText(HF_Text)//转换特殊字符
    SendMsg("把回复内容写入数据库","Td_ZhongJian");//发表帖子,把内容写入数据库
    }
    }
    } //发表回复验证HouTai.php
    case "把回复内容写入数据库" :  
    $sql="INSERT INTO name_HFLB set ".
    "tDadyMK='$MK_Id',".
    "tDadyMB='$MB_Id',".
    "tDadyZT='$ZT_Id',".
    "tUserId='$User_Id',".
    "tText='$HF_Text',".
    "tDate='".date('Y-m-d')."'";
    mysql_query($sql);//执行添加操作
    $sql=mysql_query("select * from name_HFLB where tDadyZT ='$ZT_Id' Order by tId desc");
    $rs=mysql_fetch_object($sql);
    echo $rs->tId;
    break;//把回复内容写入数据库我自己写的代码,不是很科学,但是可以实现回帖的功能的,代码还是你自己修改才能用,自己摸索一下吧。