PHP實(shí)例:用PHP將mysql數(shù)據(jù)表轉(zhuǎn)換為excel文件格式_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:PHP實(shí)例:一個(gè)比較完善的購物車類前不久做到一個(gè)項(xiàng)目需要用到購物車,考慮到可能經(jīng)常用到,所以把它封裝成一個(gè)類,以便以后調(diào)用。你可以簡單的把這個(gè)類稍微修改一下就可以用在自己的程序里了,具體使用請見。 /****************************************************************************
DB_Server = "localhost";DB_Username = "mydowns";
DB_Password = "";
DB_DBName = "mydowns";
DB_TBLName = "user";
Connect = @mysql_connect(DB_Server, DB_Username, DB_Password)
or die("Couldn't connect.");
Db = @mysql_select_db(DB_DBName, Connect)
or die("Couldn't select database.");
file_type = "vnd.ms-excel";
file_ending = "xls";
header("Content-Type: application/file_type");
header("Content-Disposition: attachment; filename=mydowns.file_ending");
header("Pragma: no-cache");
header("Expires: 0");
now_date = date('Y-m-d H:i');
title = "數(shù)據(jù)庫名:DB_DBName,數(shù)據(jù)表:DB_TBLName,備份日期:now_date";
sql = "Select * from DB_TBLName";
ALT_Db = @mysql_select_db(DB_DBName, Connect)
or die("Couldn't select database");
result = @mysql_query(sql,Connect)
or die(mysql_error());
echo("title\n");
sep = "\t";
for (i = 0; i < mysql_num_fields(result); i ) {
echo mysql_field_name(result,i) . "\t";
}
print("\n");
i = 0;
while(row = mysql_fetch_row(result))
{
schema_insert = "";
for(j=0; j{
if(!isset(row[j]))
schema_insert .= "NULL".sep;
elseif (row[j] != "")
schema_insert .= "row[j]".sep;
else
schema_insert .= "".sep;
}
schema_insert = str_replace(sep."", "", schema_insert);
schema_insert .= "\t";
print(trim(schema_insert));
print "\n";
i ;
}
return (true);
?>
分享:PHP4.3.10以下版本出現(xiàn)嚴(yán)重漏洞受影響系統(tǒng): PHP 5.0.2 PHP 5.0.1 PHP 5.0.0 PHP 4.3.9 PHP 4.3.8 PHP 4.3.7 PHP 4.3.6 不受影響系統(tǒng): PHP 5.0.3 PHP 4.3.10 描述: PHP存在輸入驗(yàn)證漏洞,遠(yuǎn)程攻擊者可以利用這個(gè)漏洞讀取系統(tǒng)文件內(nèi)容及進(jìn)行目錄遍歷攻擊。 問題一是addslashes()存在問題
相關(guān)PHP教程:
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁面代碼執(zhí)行時(shí)間
- PHP中獎(jiǎng)概率的抽獎(jiǎng)算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對(duì)圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問控制的和運(yùn)算符優(yōu)先級(jí)介紹
- 關(guān)于PHP語言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實(shí)現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國語言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
復(fù)制本頁鏈接| 搜索PHP實(shí)例:用PHP將mysql數(shù)據(jù)表轉(zhuǎn)換為excel文件格式
- 教程說明:
PHP教程-PHP實(shí)例:用PHP將mysql數(shù)據(jù)表轉(zhuǎn)換為excel文件格式
。