php-mysql-create-file
来源:互联网 发布:淘宝开店法律条款 编辑:程序博客网 时间:2024/05/18 06:46
<?
include("db.inc");
include("ToXls.inc");
$db=new db();
$sql = $_POST['sql'];
$fileTypes = $_POST['fileTypes'];
if(empty($fileTypes))
$fileTypes='prt';
if(!empty($sql)){
$sql= str_replace("/'","'",$sql);
$rt = @$db->rtAssoc($sql);
if(is_array($rt)&&!empty($rt)){
$_POST['fileTypes']($rt);
//exit();
}else{
echo "sql err! : <b>".mysql_error()."</b>";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Hang Sang Chong Admin - Accessory</title>
<meta http-equiv="content-type" content="text/html; charset=big5">
<link rel="stylesheet" type="text/css" href="../css/common.css">
</head>
<body>
<br>
<form action='' method='POST' name='create'>
<textarea name='sql' rows='10' cols='50' ><?=$sql?></textarea><br/>
<input name='fileTypes' type='radio' value='cvs' <?=$fileTypes=='cvs'?'checked':''?>>
CVS文件
<input name='fileTypes' type='radio' value='prt' <?=$fileTypes=='prt'?'checked':''?>>
直接顯示
<input name='fileTypes' type='radio' value='xls' <?=$fileTypes=='xls'?'checked':''?>>XLS文件<br/>
<input type='submit' name='submit' value='submit'>
</form>
</html>
<?
function xls($rt,$fname='download'){
$xls=new ToXls();
$rowno=0;
$xls->head($fname);
$xls->xlsBOF();
while($row = array_shift($rt)){
$rowno++;
$xls->xlsRow($row,$rowno);
}
$xls->xlsEOF();
exit();
}
function cvs($rt,$fname='download'){
header('Content-Type: text/cvs');
header("Content-Disposition: filename=$fname.csv");
while ($row = array_shift($rt)) {
$row = toCSVformat($row);
$row = join(",",$row);
print $row."/n";
}
exit();
}
function toCSVformat($in) { // for input to be assoc array
foreach ($in as $key => $val) {
if (is_string($val) && !is_numeric($val)) {
$in[$key] = ereg_replace('"','/"',$val);
$in[$key] = '"'.$val.'"';
}
}
return $in;
}
function prt($rt){
echo "<table align='center' >";
while($row=array_shift($rt)){
echo "<tr>";
foreach ($row as $key => $val) {
echo "<td> ".htmlspecialchars($val)."<td>";
}
echo "</tr>";
}
echo "<tr><td><a href='javascript:history.back();'>返回</a><td></tr>";
echo "</table>";
}
?>
- php-mysql-create-file
- PHP mysql CREATE INSERT SELECT
- navicat for mysql cannot create file
- Create+File
- PHP and MySQL: Create - Modify - Reuse
- MySQL Can't create/write to file 问题的解决
- mysql 出现 Can't create/write to file 的错误
- mysql 备份Can't create/write to file
- MySQL Can't create/write to file 问题的解决
- ubuntu mysql 数据库 Can't create/write to file
- mysql into outfile ERROR : Can't create/write to file
- Mysql ERROR 1 (HY000): Can't create/write to file
- mysql Can't create/write to file 'C:\WINDOWS\...
- 解决MYSQL出现Can't create/write to file....
- however file don't exists. Create writable for user 'mysql'.
- Class create, device create, device create file
- Class create, device create, device create file
- Class create, device create, device create file
- 花生壳+tomcat+javaweb项目的部署问题
- 加拿大政府正式为IT项目管理的成本估计作出规定
- Shell 的语法学习笔记二
- .net中使用反射的简单例子
- TBB记录2
- php-mysql-create-file
- SIP 成员参加会议过程-8
- ASP.NET 中的默认焦点和响应回车键的问题
- KMP
- HP and AIX上的date问题
- 归并排序
- Delphi多维动态数组重定义长度
- 汉诺塔问题具体解答递归方法
- 互动网计算机频道图书7日销售排行(07.09-07.15)