首页 > PHP教程

php 生成excel文件

class excel{   
  
 
    var $header = "<?xml version="1.0" encoding="utf-8"?>
<workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/tr/rec-html40">";   

阅读全文

PHP文件创建、复制、移动、删除文件

php代码

<?php session_start();
if($submit=="提交"){
$copy=$_post[copys];
$copys2=$_post[copy2];
if(copy($copy,$copys2)==true){echo "复制成功!!";}else{echo "失败!!";};
}
if($submit2=="提交"){
$moves=$_post[moves];
$moves2=$_post[moves2];
if(rename($moves,$moves2)==true){echo "移动成功!!";}else{echo "失败!!";};
}

阅读全文

php 二维数组排序与遍历

function multi_array_sort($multi_array,$sort_key,$sort=sort_asc){  
    if(is_array($multi_array)){  
        foreach ($multi_array as $row_array){  
            if(is_array($row_array)){  
                $key_array[] = $row_array[$sort_key];  
            }else{  
                return -1;  
            }  
        }  
    }else{  
        return -1;  
    }  
    array_multisort($key_array,$sort,$multi_array);  
    return $multi_array;  

阅读全文

SMARTY 中文乱码解决方法

<!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>smarty 中文乱码解决方法</title>
</head>

阅读全文

php 文件上传实例代码

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.phprm.com/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

阅读全文

php mysql 导出csv excel格式文件并保存

$times = time();
 $filename = $times.".csv"; 
 $a = "联系人,联系电话,申请时间 "; 
 
 $days = postget("days");
 
 $mktime = daystomktime($days);
 $sql = "select * from  v_tugou where ($times-times)<$mktime";
 $db = new db();
 $result = $db->query( $sql );
 $rs = $db->fetch($result,0);
 foreach($rs as $v=>$vv)
 {  
 $a.=$vv['name'].','. $vv['mo'].",";
 $a.=date('y-m-d ',$vv['times'])." ";  
 }
 //echo $a;
 $hod = fopen ($filename,"w+");
 if( fwrite($hod,$a) )
 {
  echo "生成excel文件成功,点击<a href=$filename target=_blank>右击另存为excel文档</a>";
 }
 

阅读全文