Recently sunny Little did a PHP alumni, the students themselves there to add or modify names, mailboxes, OICQ and other information, and save in the MySQL database. One day sunny little suddenly thought, if can use PHP to generate a file, for students to download and import the data into their Foxmail address book, that would be so good! The
says dry, and soon Xiao Yang will launch the function. How did that happen? This is only illustrated by exporting names, mailboxes, and Oicq three items.
To import the Foxmail address Book, you must first understand the file contents and format of the import Foxmail Address Book. Open Foxmail4.2 An account's address book, as you can see in its menu bar "Tools"-"import", Foxmail supports the import of two external files: CSV file and WAB file. We chose to generate a CSV file. What about the content and format of the Foxmail CSV file that you can import? Let's first export a CSV file from Foxmail to see. Select a folder in the Foxmail address book that is not empty, execute tools-Export-text files, and save the file named "TEMP." CSV, select "Name", "E-mail Address" and "OICQ" in "Please select output field" in "Next" and click "Finish" to generate "TEMP" in the specified path. CSV file. If you install 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 of Excel, double-click Open, its interface as shown in the figure.
We still have no way of knowing its write format in this case. Will "TEMP." CSV file to open with Notepad, you can find that its format is very simple: as the figure, the first line of the file is Foxmail Address Book field, the other row is the corresponding value of the field, the fields and values are separated by commas in English. So we are in PHP in this format to generate CSV files, others can download and import their foxmail!
But there is still one problem to solve, that is, since the file is separated by commas, if there is a comma in the database record (note: If the following symbols do not specify the English symbol) What should I do? Of course you can first replace the comma in the data with the Chinese comma, but there is actually a way that is, if the corresponding field in the CSV file has a double quotation mark ("" "" ") as the delimited value, the English comma is not used as the delimited value, and the two consecutive double quotes in the field (that is," ") are only displayed as one. Instead of being a delimited value.
With these realizations, we can write PHP files that export CSV files:
Run the above PHP file on the server, and the downloaded "tofoxmail.csv" file is opened in Notepad as shown in the picture.
Click the "Tools"-"Import"-"CSV file" in the Foxmail Address Book ..., a lot of data in the database all of a sudden have been imported, this idea is not bad!
(the above procedures are tested in both Apache+php4+mysql and Iis+php4+mysql.) )