TM_skyinfo: 如下将表 table_1 的field_1 字段内容导出到d盘temp.txt文件内。select field_1 from table_1 into outfile 'd:/temp.txt';
TM_skyinfo: 如下将表 table_1 的field_1 字段内容导出到d盘temp.txt文件内。select field_1 from table_1 into outfile d:/temp.txt;
可能是小弟没说清楚 汗····· 是在wed页面上的代码 数据库里面我会
<?php //连接数据,用户名密码改成自己的 $link = mysql_connect("localhost","root","") or die("Could not connect: " . mysql_error()); //选择要导出的数据库,这里是ucenter,改成自己的 mysql_select_db("ucenter",$link); //防止中文乱码,设置编码 mysql_query("SET NAMES gb2312") or die(mysql_error()); //要导出的表和字段,这里为uchome_space表中的name字段 $result = mysql_query("SELECT name FROM `uchome_space`"); //得到结果 $txt=""; while ($row = mysql_fetch_array($result)) { $txt.=$row[0]."\r\n"; } mysql_free_result($result); //存入txt文件 file_put_contents("test.txt",$txt); ?>
方法一 SELECT column_name FROM information_schema.columns WHERE table_schema='你的数据库名' AND table_name = '你的数据表名'方法二 DESC 你的数据表名然后用file_put_contents('txt文档名','查出来的内容');这样做最简单了 我公司招php程序员啊,一年半工作经验,有意者请发邮件[email protected]
TM_skyinfo: 简单,两句完成。 $db = new mysqli('host','username','passwd','dbname'); //建立数据库连接,hosts是服务器地址;username是用户名,passwd密码,dbname是数据库 $db->query("select field_1 from table_1 into outfile d:/temp.txt"); //完成
用sql也简单啊
select一下,写入txt就行了。
如下将表 table_1 的field_1 字段内容导出到d盘temp.txt文件内。select field_1 from table_1 into outfile 'd:/temp.txt';
如下将表 table_1 的field_1 字段内容导出到d盘temp.txt文件内。select field_1 from table_1 into outfile d:/temp.txt;
<?php
//连接数据,用户名密码改成自己的
$link = mysql_connect("localhost","root","") or die("Could not connect: " . mysql_error());
//选择要导出的数据库,这里是ucenter,改成自己的
mysql_select_db("ucenter",$link);
//防止中文乱码,设置编码
mysql_query("SET NAMES gb2312") or die(mysql_error());
//要导出的表和字段,这里为uchome_space表中的name字段
$result = mysql_query("SELECT name FROM `uchome_space`");
//得到结果
$txt="";
while ($row = mysql_fetch_array($result))
{
$txt.=$row[0]."\r\n";
} mysql_free_result($result);
//存入txt文件
file_put_contents("test.txt",$txt);
?>
FROM information_schema.columns
WHERE table_schema='你的数据库名' AND table_name = '你的数据表名'方法二 DESC 你的数据表名然后用file_put_contents('txt文档名','查出来的内容');这样做最简单了
我公司招php程序员啊,一年半工作经验,有意者请发邮件[email protected]
简单,两句完成。
$db = new mysqli('host','username','passwd','dbname');
//建立数据库连接,hosts是服务器地址;username是用户名,passwd密码,dbname是数据库
$db->query("select field_1 from table_1 into outfile d:/temp.txt"); //完成