Use PHP to import data to Foxmail

Source: Internet
Author: User

Recently, Xiaoyang made a PHP transcript where students added or modified the name, email address, OICQ, and other information and stored them in the mySQL database. One day, Xiaoyang suddenly thought that it would be nice if he could use PHP to generate a file for students to download and import the data into their Foxmail address book!

Just do what you want, and soon Xiaoyang will launch this function. How is that implemented? Here, we only describe the exported name, email address, and OICQ.

You can import materials to the Foxmail address book. Of course, you must first understand the content and format of the files imported into the Foxmail address book. Open the address book of an account in Foxmail4.2. In the menu bar "Tools"-"import", you can see that Foxmail supports the import of two types of external files: "CSV files" and "Wab files ". Select generate CSV file. What is the content and format of CSV files that can be imported into Foxmail? Let's first export a CSV file from Foxmail. In the Foxmail Address Book, select a folder with a non-empty record, execute "tool"-"Export"-"text file", and save the file name as "TEMP. CSV. In "Next", select "name", "email address", and "OICQ" in "select output field ", after clicking "finish", the "TEMP. CSV file. If you have installed the Microsoft Office series, you will find that this is a file opened by default in EXCEL. In fact, it is a comma-separated value File in EXCEL. After you double-click it, its interface is displayed.

  

In this case, we still cannot know its write format. Set "TEMP. the CSV file is opened in notepad, and the format is very simple: the first line of the file is the field in the Foxmail address book, and the other lines are the value corresponding to the field, fields and values are separated by commas. So we generate CSV files in PHP in this format, and others can download and import them to their Foxmail!

  

However, there is another problem to be solved, that is, since the files are separated by commas (,), What should I do if the database records contain English commas? Of course, you can replace the comma in the data with a Chinese comma, but there is another way, that is, if the two ends of the corresponding fields in the CSV file are added with double quotation marks """) separate values. The English comma in the field is not used as the separated values, and two consecutive double quotes (") in the field are only displayed as one, not as the separated values.

With these knowledge, we can compile the PHP file for exporting CSV files:

  

Run the PHP file on the server and download the downloaded tofoxmail.csv file. use NotePad to open the file.

In the Foxmail Address Book, click "Tools"-"import"-"CSV file "......, A lot of data in the database is imported at once. This is a good idea!

  

(The above programs have passed the test in Apache + PHP4 + mySQL and IIS + PHP4 + mySQL .)

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.