Home >Backend Development >PHP Tutorial >php mysql export csv excel format file and save it_PHP tutorial

php mysql export csv excel format file and save it_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 17:04:561211browse

php mysql export csv excel format file and save it This is a tool that I wrote for my own use. It uses PHP to export the data of mysql database and save it into a csv file. It is also available for download. The principle is very simple. It is to check out the mysql data and then save it to a .csv file in csv format. OK.

php tutorial mysql tutorial export csv excel format file and save it
This is a tutorial I wrote when I was using PHP to export mysql database. The data is saved into a csv file and provided for download. The principle is very simple. It is to check out the mysql data and then save it to a .csv file in csv format. It’s ok.
*/

$times = time();
$filename = $times.".csv";
$a = "Contact person, contact number, application time n";

$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'])." rn ";
}
//echo $a;
$hod = fopen ($filename,"w+");
if( fwrite($hod,$a) )
{
echo "The excel file was generated successfully, clickright-click to save as excel document";
}


/*
Data structure
--
-- Table structure `hn_tugou`
--

create table if not exists `v_tugou` (
`id` int(4) not null auto_increment,
`name` varchar(20) not null default '0',
`mo` varchar(20) not null default '0',
`times` int(4) default null,
`ip` varchar(20) not null default '0',
primary key (`id`)
) engine=myisam default charset=utf8 auto_increment=2 ;

--
--Export data in the table `hn_tugou`
--

insert into `hn_tugou` (`id`, `name`, `mo`, `times`, `ip`) values
(1, 'adsense', 'www.bKjia.c0m', 1283241159, '192.168.0.119');

Original articles on this site are reproduced from http://www.bKjia.c0m/phper/php.html
*/

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630804.htmlTechArticlephp mysql export csv excel format file and save it. This is a method I wrote for my own use and exported using php The data of the mysql database is saved into a csv file and provided for download. The principle is very simple...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn