首页 > PHP教程

js 树形菜单(php ajax可刷新)

<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.phprm.com/tr/xhtml1/dtd/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>simpletree drag</title>
<style>
body
{
 font: normal 12px arial, tahoma, helvetica, sans-serif;
 margin:0;
 padding:20px;
}
.simpletree
{
 
 margin:0;
 padding:0;
 /*
 overflow:auto;
 width: 250px;
 height:350px;
 overflow:auto;
 border: 1px solid #444444;
 */
}
.simpletree li
{
 list-style: none;
 margin:0;
 padding:0 0 0 34px;
 line-height: 14px;
}
.simpletree li span
{
 display:inline;
 clear: left;
 white-space: nowrap;
}
.simpletree ul
{
 margin:0;
 padding:0;
}
.simpletree .root
{
 margin-left:-16px;
 background: url(http://pic3.phprm.com/2010/10/16/root.jpg) no-repeat 16px 0 #ffffff;
}
.simpletree .line
{
 margin:0 0 0 -16px;
 padding:0;
 line-height: 3px;
 height:3px;
 font-size:3px;
 background: url(http://pic3.phprm.com/2010/10/16/line_bg.jpg) 0 0 no-repeat transparent;
}
.simpletree .line-last
{
 margin:0 0 0 -16px;
 padding:0;
 line-height: 3px;
 height:3px;
 font-size:3px;
 background: url(http://pic3.phprm.com/2010/10/16/spacer.jpg) 0 0 no-repeat transparent;
}
.simpletree .line-over
{
 margin:0 0 0 -16px;
 padding:0;
 line-height: 3px;
 height:3px;
 font-size:3px;
 background: url(http://pic3.phprm.com/2010/10/16/line_bg_over.jpg) 0 0 no-repeat transparent;
}
.simpletree .line-over-last
{
 margin:0 0 0 -16px;
 padding:0;
 line-height: 3px;
 height:3px;
 font-size:3px;
 background: url(http://pic3.phprm.com/2010/10/16/line_bg_over_last.jpg) 0 0 no-repeat transparent;
}
.simpletree .folder-open
{
 margin-left:-16px;
 background: url(images/collaps教程able.gif) 0 -2px no-repeat #fff;
}
.simpletree .folder-open-last
{
 margin-left:-16px;
 background: url(http://pic3.phprm.com/2010/10/16/collapsable-last.jpg) 0 -2px no-repeat #fff;
}
.simpletree .folder-close
{
 margin-left:-16px;
 background: url(http://pic3.phprm.com/2010/10/16/expandable.jpg) 0 -2px no-repeat #fff;
}
.simpletree .folder-close-last
{
 margin-left:-16px;
 background: url(http://pic3.phprm.com/2010/10/16/expandable-last.jpg) 0 -2px no-repeat #fff;
}
.simpletree .doc
{
 margin-left:-16px;
 background: url(http://pic3.phprm.com/2010/10/16/leaf.jpg) 0 -1px no-repeat #fff;
}
.simpletree .doc-last
{
 margin-left:-16px;
 background: url(http://pic3.phprm.com/2010/10/16/leaf-last.jpg) 0 -1px no-repeat #fff;
}
.simpletree .ajax
{
 background: url(http://pic3.phprm.com/2010/10/16/spinner.jpg) no-repeat 0 0 #ffffff;
 height: 16px;
 display:none;
}
.simpletree .ajax li
{
 display:none;
 margin:0;
 padding:0;
}
.simpletree .trigger
{
 display:inline;
 margin-left:-32px;
 width: 28px;
 height: 11px;
 cursor:pointer;
}
.simpletree .text
{
 cursor: default;
}
.simpletree .active
{
 cursor: default;
 background-color:#f7be77;
 padding:0px 2px;
 border: 1px dashed #444;
}
#drag_container
{
 background:#ffffffwww.phprm.com;
 color:#000;
 font: normal 11px arial, tahoma, helvetica, sans-serif;
 border: 1px dashed #767676;
}
#drag_container ul
{
 list-style: none;
 padding:0;
 margin:0;
}

阅读全文

php递归删除目录所有文件

<meta http-equiv="content-type" content="text/html; charset=gb2312">

<?php
function tree($directory)
{
$mydir=dir($directory);
echo "<ul> ";
while($file=$mydir->read()){
if((is_dir("$directory/$file")) and ($file!=".") and ($file!=".."))
{echo "<li><font color="#ff00cc"><b>$file</b></font></li> ";
tree("$directory/$file");
}
else{
    $a = explode('.',$file);
    if($a[1] == 'html' || $a[1] == 'htm')
   {
        //unlink($file);
            echo "<li>$file</li> ";
        }   
   

阅读全文

php ajax分页代码

header("content-type: text/html;charset=gbk");//输出编码,避免中文乱码
?>
<html>
<head>
<title>ajax分页演示</title>
<script language="网页特效" >
var http_request=false;
  function send_request(url){//初始化,指定处理函数,发送请求的函数
    http_request=false;
 //开始初始化xmlhttprequest对象
 if(window.xmlhttprequest){//mozilla浏览器
  http_request=new xmlhttprequest();
  if(http_request.overridemimetype){//设置mime类别
    http_request.overridemimetype("text/xml");
  }
 }
 else if(window.activexobject){//ie浏览器
  try{
   http_request=new activexobject("msxml2.xmlhttp");
  }catch(e){
   try{
   http_request=new activexobject("microsoft.xmlhttp");
   }catch(e){}
  }
    }
 if(!http_request){//异常,创建对象实例失败
  window.alert("创建xmlhttp对象失败!");
  return false;
 }
 http_request.onreadystatechange=processrequest;
 //确定发送请求方式,url,及是否同步执行下段代码
    http_request.open("get",url,true);
 http_request.send(null);
  }
  //处理返回信息的函数
  function processrequest(){
   if(http_request.readystate==4){//判断对象状态
     if(http_request.status==200){//信息已成功返回,开始处理信息
   document.getelementbyid(reobj).innerhtml=http_request.responsetext;
  }
  else{//页面不正常
   alert("您所请求的页面不正常!");
  }
   }
  }
  function dopage(obj,url){
   document.getelementbyid(obj).innerhtml="<font color='green' font-size='12'>正在读取数据...</font>";
   send_request(url);
   reobj=obj;
   }
 
</script>
<style>
/* css教程 document */
#result ul li{
 height:20px;
 width:auto;
 display:block;
 color:#999;
 border:1px solid #999;
 float:left;
 list-style:none;
 font-size:12px;
 margin-left:5px;
 line-height:20px;
 vertical-align:middle;
 text-align:center;
 }
#result ul li a:link{
 width:50px;
 height:20px;
 display:block;
 
 line-height:20px;
 background:#09c;
 border:1px solid #fff;
 color:#fff;
 text-decoration:none;
 }
#result ul li a:hover{
 width:50px;
 height:20px;
 display:block;
 
 line-height:20px;
 background:#09c;
 border:1px solid #fff;
 color:#f60;
 text-decoration:none;
 }
</style>
</head>
<body>
<div id="result">
<?php
$page=isset($_get['page'])?intval($_get['page']):1;        //这句就是获取page=18中的page的值,假如不存在page,那么页数就是1。
$num=10;                                      //每页显示10条数据

阅读全文