<?php /** * Created by PhpStorm. * User: Administrator * Date: 2016/9/17 * Time: 9:28 */ header("content-type:text/html;charset=utf-8"); session_start(); $filename='1.html'; if(file_exists($filename)&&(time()-filemtime($filename)<=2000)){ echo 0; echo file_get_contents($filename); }else{ $pdo=new PDO('mysql:host=localhost;dbname=test','root','root'); $pdo->exec("set names utf8"); $data=$pdo->query("select * from stu")->fetchAll(PDO::FETCH_ASSOC); //print_r($data); ob_start(); include 'index2.php'; $str=ob_get_contents(); //echo $str; ob_clean(); file_put_contents($filename,$str); echo 1; echo $str; } //模板<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <script src="jquery-2.1.1.min.js"></script> <script> //获取session数据 $(function(){ var url='checkname.php'; $.get(url,function(msg){ $("div").html(msg); }) }) </script> </head> <body> <center> <div> </div> <table border="1"> <th>id</th> <th>姓名</th> <th>性别</th> <th>年龄</th> <th>操作</th> <?php foreach($data as $v){?> <tr> <td><?php echo $v['id']?></td> <td><?php echo $v['name']?></td> <td><?php echo $v['sex']?></td> <td><?php echo $v['age']?></td> <td id="<?php echo $v['id']?>"> <button class="del">删除</button>|| <a href="up.php?id=<?php echo $v['id'];?>">修改</a>|| <a href="add.html">添加</a></td> </tr> <?php }?> </table> </center> </body> </html> <script> $(function(){ $(".del").click(function(){ var obj=$(this); var id=$(this).parent("td").attr('id'); var url='http://localhost/m9/d917/del.php'; $.get(url,{id:id},function(msg){ obj.parents("tr").remove(); }) }); }) </script>
//缓存
1.html
静态化 代码 实现模拟 参考
最新推荐文章于 2019-04-21 11:26:31 发布