将mysql数据导出到MS

将mysql数据导出到MS

本文介绍了将mysql数据导出到MS excel在本地但不在服务器上运行良好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码很简单。 

在当地工作得很好。但是当我在服务器上的网站上使用它时。它仅显示带有数据的表。它不会在Excel中导出该数据。

请尽快帮助。

order_no order_date order_name total_amount
100000705 2017-05-07 MR。 PRADEEP Y 113500
100000708 2017-05-11 MR。 A SRINIVASA RAO 5448
100000725 2017-05-30 MR。 A SRINIVASA RAO 77180

这是我点击导出链接时可以看到的结果。

在本地wampserver中,它很容易导出。





我尝试过:



< pre>< title>订单导出< / title> 

< body>


<?php
header('Content-Type:application / xls');
header('Content-Disposition:attachment; filename = download.xls');

$ con = mysqli_connect('localhost','suresafe_admin','iwant $ 100','suresafe_suresafety');



$ query =select * from`orders_approval`其中`approve` ='1'和`company_name` ='GAVL-F111';

$ result = mysqli_query($ con,$ query);
$ output ='';
if(mysqli_num_rows($ result)> 0)
{
$ output。='?>
< table class =tablebordered =1>
< tr>
< th> order_no< / th>
< th> order_date< / th>
< th> order_name< / th>
< th> total_amount< / th>

< / tr><?php
';
while($ row = mysqli_fetch_array($ result))
{
$ output。='
< tr>
< td>'。$ row [order_no]。'< / td>
< td>'。$ row [order_date]。'< / td>
< td>'。$ row [order_name]。'< / td>
< td>'。$ row [total_amount]。'< / td>

< / tr>
';
}
$ output。='< / table>';


}?>


< / body>
< / html>
解决方案



The code is simple.

Working well in local. But when i use this in my website on server. It shows only Table with data. It don't export that data in excel.

Please help ASAP.

order_no    order_date  order_name  total_amount
100000705   2017-05-07  MR. PRADEEP Y   113500
100000708   2017-05-11  MR. A SRINIVASA RAO     5448
100000725   2017-05-30  MR. A SRINIVASA RAO     77180

Here is the result I can see when i click on export link.

In local wampserver, It is easily exported.



What I have tried:

<pre><title>Orders Export</title>

<body>


<?php
 header('Content-Type: application/xls');
  header('Content-Disposition: attachment; filename=download.xls');

$con = mysqli_connect('localhost','suresafe_admin','iwant$100','suresafe_suresafety');



    $query = "select * from `orders_approval` where `approve`='1' and `company_name`='GAVL-F111'";

    $result = mysqli_query($con,$query);
$output = '';
if(mysqli_num_rows($result) > 0)
 {
  $output .= '?>
   <table class="table" bordered="1">
                    <tr>
                         <th>order_no</th>
                         <th>order_date</th>
                         <th>order_name</th>
                         <th>total_amount</th>

                    </tr><?php
  ';
  while($row = mysqli_fetch_array($result))
  {
   $output .= '
    <tr>
                         <td>'.$row["order_no"].'</td>
                         <td>'.$row["order_date"].'</td>
                         <td>'.$row["order_name"].'</td>
                         <td>'.$row["total_amount"].'</td>

                    </tr>
   ';
  }
  $output .= '</table>';


 }?>


</body>
</html>
解决方案




这篇关于将mysql数据导出到MS excel在本地但不在服务器上运行良好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 07:50