我要做个局部刷新这两个字段,比如1分钟刷新一次,数据从mysql数据库里调取的! 
<td><?php echo $row['status']?></td> 
<td><?php echo $row['time']?></td>

解决方案 »

  1.   

    去看看ajax部分。
      

  2.   

    去看ajax,没别的可说。
      

  3.   

    $("#div").load(url,function(data){xxxx}).........
      

  4.   

    仅供参考;#data.php
    if(isset($_GET['refresh'])){
        //数据库查询操作
        //输出结果
        echo "<td>{$row['status']}</td><td>{$row['time']}</td>";
    }#页面js
    <script>
    var xmlHttp;
    var timer = null;
    var timerRunning = false;
    var url; function createXMLHttpRequest() {
    if(window.XMLHttpRequest) {
    xmlHttp = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    } function statusStop (){
    if(timerRunning){
       clearTimeout(timer);
    }
    timerRunning = true;
    } /* ------------------- 间隔查询 ------------------- */
    function autoDeep(){
    createXMLHttpRequest();
    url = "data.php?refresh="+Math.random();   //后端查询数据页面
    method = "GET";
    xmlHttp.open(method,url,true);
    xmlHttp.onreadystatechange = show();   //执行回调函数,处理后端返回的结果
    xmlHttp.send(null);
    timerRunning = false;
    timer = setTimeout('autoDeep()',5000);   //此处为5秒执行一次
    }
       
            function show(){
    if (xmlHttp.readyState == 4){
    if (xmlHttp.status == 200){
    var text = xmlHttp.responseText;
    document.getElementById("route").innerHTML = text;  //这里将返回的数据text放入页面id为route的div中。
    }else {
    alert("response error code:"+xmlHttp.status);
    }
    }
            } function statusBegin(){
    statusStop();
    autoDeep();
    } statusBegin();</script>#前端页面
    <div id="route">
        <td><?php echo $row['status']?></td> 
        <td><?php echo $row['time']?></td>
    </div>
      

  5.   

    data.php  是什么页面?
      

  6.   


    #注意
    url = "data.php?refresh="+Math.random();   //后端查询数据页面#js中的url指向你的后端php处理数据的页面,即,$rows的出处,所以;
    #data.php
    if(isset($_GET['refresh'])){    //这里接收url的参数refresh
        //数据库查询操作,即你的$rows出处
        //输出结果
        echo "<td>{$row['status']}</td><td>{$row['time']}</td>";
    }
      

  7.   

    楼主可以通过jquery ajax进行。每隔一分钟刷新一下页面。
      

  8.   

    但是这个页面不能直接这样写呀? 那个$row  调不到值?本人菜鸟...求解
      

  9.   

    我擦,我的注释不是只用来看的,是要你自己写你的查询代码:#data.php
    if(isset($_GET['refresh'])){    //这里接收url的参数refresh
        //数据库查询操作,即你的$rows出处
        $sql = "select * from table";
        $res = mysql_query($sql);
        if(!$res)
             die("SQL:{$sql}<br>Error:".mysql_error());
        if(mysql_affected_rows() > 0){
             while($rows=mysql_fetch_array($res,MYSQL_ASSOC)){
                  echo "<td>{$row['status']}</td><td>{$row['time']}</td>";
             }
        }else{
             echo "查询失败".mysql_error();
        }
    }
    #ajax会将该页面的输出内容返回前端页面
      

  10.   

    只是2个值的话 ,建议使用 json