解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
    <title>无标题文档</title>
    </head><body>
    <?php
        header("Content-type:text/html;charset='GBK'");
    $id=$_GET["key"];
        $link=mysql_connect("localhost","root","");
    mysql_select_db("enterprise");
    mysql_query("set names 'GBK'");
    $sql="select * from etp_news where id=".$id;
    $result=mysql_query($sql);
    while($rs = mysql_fetch_object($result)){

    $tit=$rs->tit;
    $cont=$rs->content;
    $name=$rs->source;
    ?>
          <form name="form1">
         <table>
             <tr><td>标题</td><td><input type="text" name="title" id="title" value="<?php echo $tit;?>" /></td><td></td></tr>
                <tr><td>正文</td><td><textarea name="cent" id="cent"><?php echo $cont;?></textarea></td><td></td></tr>
                <tr><td>作者</td><td><input type="text" id="name" name="name" value="<?php echo $name;?>" /></td><td></td></tr>
                 <tr><td></td><td colspan="2"><input type="hidden" name="id" id="id" value="<?php echo $id;?>" />
                 <input type="button" name="but" onclick="upd()" value="提交" /></td></tr>
            </table>
        </form>
       <?php }   ?>
       
       <script type="text/javascript">
        var xmlHttp;
    function createXMLHttpRequest(){
    if(window.ActiveXObject){
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }else if(window.XMLHttpRequest){
    xmlHttp=new XMLHttpRequest();
    }

    }


    function upd(){
    createXMLHttpRequest();

    var id=document.getElementById("id").value;
    var title=document.getElementById("title").value;
    var name=document.getElementById("name").value;
    var cent=document.getElementById("cent").value;
    var str="id="+id+"&title="+title+"&name="+name+"&cent="+cent;
    var url="php/update.php";
    xmlHttp.open("POST",url,true);
    xmlHttp.onreadystatechange=callback;
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xmlHttp.send(str);

     }
     
     
     function callback(){
     if(xmlHttp.readyState==4){
     if(xmlHttp.status==200){
     var  strs=xmlHttp.responseText; 

     if(strs=="1"){ 
     alert("数据已修改");
     }
     }
     }
     }
       </script>
    </body>
    </html>
      

  2.   

    你怎么只看返回内容的后半部呢?前半部是 php 的错误信息,为什么视而不见呢?
    两部分合在一起还能算是 XML 吗?
      

  3.   

    错误信息明确的告诉你 sel_News.php 第 18 行处变量 $content 不存在
    你不按错误信息改错,光抱拳有什么用?
      

  4.   

    不加$ctent.  只显示一条
    加了就出错,找不到ctent,我需要让他循环显示啊