MySQL 数据库导入与导出,用到的工具知,navicat,步骤如下:打开navicat,点击连接,输入连接名,主" />
乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > 如何能够将MySQL当中的表数据通过<em>PHP</em>实现<em>EXCEL&

如何能够将MySQL当中的表数据通过<em>PHP</em>实现<em>EXCEL&

作者:乔山办公网日期:

返回目录:excel表格制作





MySQL 数据库导入与导出,用到的工具,navicat,步骤如下:

  1. 打开navicat,点击连接,输入连接名,主机名或者ip地址,端口,用户名,密码,点击确定。

2.以aabb为示例数据库,选择aabb数据库双击。

3.导入数据库,右击aabb数据库选择运行sql文件,选择好要导入的数据文件以后,点击开始。

4.显示以下信息,说明导入成功。

5.导出数据库,右击aabb数据库选择转储sql文件,选择数据结构和数据,然后选择存储路径点击保存。

6.显示以下信息说明导出成功。

注意事项:navicat非免费软件。



下面是我最初研究生成Excel文件的代码,后来e79fa5e98193e58685e5aeb9335我用面向对象重写,你先看看这个代码吧,很简单的,想要面向对象的再联系!
<?php
$DB_Server = "localhost";
$DB_Username = "root";
$DB_Password = "root";
$DB_DBName = "lost_property";
$DB_TBLName = "wuping";
$savename = date("YmjHis");
$Connect = @mysql_connect($DB_Server, $DB_Username, $DB_Password) or die("Couldn't connect.");
mysql_query("Set Names 'gbk'");
$file_type = "vnd.ms-excel";
$file_ending = "xls";
header("Content-Type: application/$file_type;charset=big5");
header("Content-Disposition: attachment; filename=".$savename.".$file_ending");
//header("Pragma: no-cache");

$now_date = date("Y-m-j H:i:s");
$title = "数据库名:$DB_DBName,数据表:$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< mysql_num_fields($result);$j++) {
if(!isset($row[$j]))
$schema_insert .= "NULL".$sep;
else if ($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);
?>

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网