Php exports data to execl file format
Php exports data to execl file format
- ? Session_start ();
- $ SQL _excel = "";
- If (isset ($ _ SESSION ["excel"])
- {
- $ SQL _excel = $ _ SESSION ["excel"];
- }
- // Unset ($ _ SESSION ["excel"]);
- $ Conn = mysql_connect ("localhost", "root ","");
- Mysql_select_db ("test ");
- Mysql_query ("set names utf8", $ conn );
- $ Result = mysql_query ($ SQL _excel );
- Header ("Content-type: application/vnd. ms-excel ");
- Header ("Content-Disposition: attachment?filename=export_data.xls ");
- // $ Result = mysql_query ($ SQL _excel );
- $ Result = mysql_query ($ SQL _excel );
- While ($ arr = mysql_fetch_assoc ($ result )){
- $ Content [] = $ arr;
-
- }
- // Print_r ($ content );
- $ Table ='
- $ Table. ='
- $ Table. ='
- Foreach ($ content as $ key => $ value ){
- $ Table. ="
- $ Table. ="
- $ Table. ="
- $ Table. ="
- $ Table. ="
- $ Table. ="
- $ Table. ="
- $ Table. ='
- }
- $ Table. ='
- $ Table. ="
- $ Table. ='
';
Id |
Title |
Phone Number |
Address |
Review status |
Content |
Message time |
';
';
";
". $ Value ['id'].' | ';
". $ Value ['title'].' | ';
". $ Value ['phone'].' | ';
". $ Value ['address'].' | ';
". $ Value ['ischeck'].' | ';
". $ Value ['content'].' | ';
". Substr ($ value ['datetime'], 0, 11 ).' | ';
';
';
';
- Echo $ table;
- ?>
- Session_start ();
- $ Link = mysql_connect ("localhost", "root", "") or die ("cocould not connect:". mysql_error ());
- Mysql_query ("set names utf8", $ link );
- Mysql_select_db ("test ");
- $ Sqls = "select * from news order by id desc ";
- $ _ SESSION ["excel"] = $ sqls;
- $ Rs1 = mysql_query ($ sqls );
- While ($ arr = mysql_fetch_assoc ($ rs1 )){
- $ Content [] = $ arr;
- }
- Echo'
- Echo'
- Echo'
- Echo'
- Echo'
- Echo'
- Echo'
- Echo'
- Echo'
- Echo'
- Echo'
- Echo'
- Echo'
- Echo'
- Foreach ($ content as $ k => $ v ){
- Echo"
- Echo"
- Echo"
- Echo"
- Echo"
- Echo"
- Echo"
- Echo"
- }
- Echo'
- Echo"
- Echo'';
- Echo'
';
Video List (index: lanmu displayed on the home page: displayed on the video page)
';
';
';
Serial Number | ';
User uid | ';
Display position | ';
File name | ';
Video name | ';
Video introduction | ';
Upload time | ';
';
';
';
";
$ K | ";
{$ V ['title']} | ";
{$ V ['phone']} | ";
{$ V ['address']} | ";
{$ V ['ischeck']} | ";
{$ V ['content']} | ";
{$ V ['datetime']} | ";
";
';
';
- // Var_dump ($ content );
- Mysql_free_result ($ rs1 );
- Mysql_close ($ link );
- ?>
|