Phpmysql export csvexcel files and save _ PHP Tutorial

Source: Internet
Author: User
Tags mysql tutorial php mysql
Export and save the csvexcel file in phpmysql. Phpmysql exports and saves csvexcel files. this is a file I wrote when using php to export mysql database data and save it as a csv file, and provides download, the principle is very simple. in php mysql, export a csv excel file and save it. this is a file I wrote when I was using php scripts.

Php Tutorial mysql tutorial export csv excel file and save
This is a php ghost file I wrote in my own time.
*/

$ Times = time ();
$ Filename = $ times. ". csv ";
$ A = "contact, 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 ['M']. ",";
$ A. = date ('Y-m-D', $ vv ['Times']). "rn ";
}
// Echo $;
$ Hod = fopen ($ filename, "w + ");
If (fwrite ($ hod, $ ))
{
Echo "the excel file is generated successfully. right-click and choose save as excel file ";
}


/*
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 the table data 'hn _ tugou'
--

Insert into 'hn _ tugou' ('id', 'name', 'M', 'Times ', 'IP') values
(1, 'adsense ', 'www. bKjia. c0m', 1283241159, '192. 168.0.119 ');

This site Original article reprinted from http://www.bKjia. c0m/phper/php.html
*/

Http://www.bkjia.com/PHPjc/630804.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630804.htmlTechArticlephp mysql export csv excel format file and save this is a I write in my own use of php export mysql database data saved as a csv file, and provide download, the principle is simple...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.