To export PHP Data to an excel table, PHP has excellent support in this aspect. PHP can output a simple excel table in just a few simple sentences.
PHP code:
Header ("Content-type: application/vnd. ms-excel ");
Header ("Content-Disposition: attachment?filename=users.xls ");
Echo "Company Name "."";
Echo "User Name "."";
Echo "password "."";
Echo "second-level domain name "."";
Echo "";
Foreach ($ result [result] as $ val ){
Echo "$ val-> ComName "."";
Echo "$ val-> UserName "."";
Echo "$ val-> UserTruePw "."";
Echo emptyempty ($ val-> DoMainName )? :( Http: //. $ val-> DoMainName..jiaomai.com )."";
Echo "";
}
?>
Pay attention to the encoding problem, because the table generally outputs UTF-8 encoding. Garbled characters appear when I output data in table form (table + tr + td .... Because my page code is GB2312 and can be converted to iconv, it is best to use the above method to output the code to prevent garbled characters.