Most of the time, the data in the database needs to be exported to excel. The following is the easiest way to export data without the need for an excel class. even if the function is simple, the project quot; has no complex requirements; quick effect quot ;. first define the header information to output an ex... most of the time, the data in the database needs to be exported to excel. The following is the simplest method. you do not need to export the excel class. even if the function is simple, the project with no complex requirements is "quick effect ".
Define the header information to output an excel file, and then echo the database information in the form of a table. the code is as follows:
"; // Export the header (that is, the fields in the table) while ($ row = mysql_fetch_array ($ res) {$ t_field [] = $ row ['field']; // F in Field must be capitalized; otherwise, no echo is returned"". $ Row ['field']."";} Echo""; // Export 100 pieces of data $ SQL =" select * from users limit 100 "; $ res = mysql_query ($ SQL); while ($ row = mysql_fetch_array ($ res )) {echo""; Foreach ($ t_field as $ f_key) {echo"". $ Row [$ f_key]."";} Echo"";} Echo"";
Address:
Reprinted at will, but please attach the article address :-)