PHP Export data in CSV format

Source: Internet
Author: User
PHP Export data, formatted as CSV without Phpexcel class, is there any other way? How should I write a class? Thanks a lot!


Reply to discussion (solution)

$fp = fopen (' CSV file name ', ' W '), $rs = mysql_query (' select * from Tbl_name ') and while ($row = Mysql_fetch_assoc ($rs) {  fputcsv ( $FP, $row);} Fclose ($FP);

Moderator Positive Solution +1

If the data is large, it will be slow to write.

You write in PHP code, slow is normal
If you have access to the database directory, you can also build a engine=csv table to copy the data in

Let's talk about where to export the data.

Export the data queried in the database!

 
  ";            Processing the data here        }    }        

Backstage, slow down, it's okay.
For users, you have to consider limiting the frequency of user use
or other ways to speed things up, like extensions or something.

Slow and this code seems to be okay not to query the database

  • 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.