'; while($ row = mysqli_fetch_array($ result)) { $ output。=' '; } $输出。=' Id 客户名称 客户IC: 客户状态: 客户电子邮件 客户地址 '。$ row [id]。 。$行[ 客户id]。 。$行[ 客户名称]。 。$行[ CustomerNric]。 。$行[ 国家]。 。$行[ 电子邮件]。 。$行[ 地址。 ' '; header(Content-Type:application / xls); header( Content-Disposition:attachment; filename = download.xls); echo $ output; } }I have follow instruction on youtube about converting MYSQL data to excel, btw I have try their coding with their database and its work. But when i change the database in that coding with my own database, its does not work*This coding that i follow from youtube*data.php Userexcel.php <?php$connect = mysqli_connect("localhost", "root", "", "test_db");$output = ''; if(isset($_POST["export_excel"])){$sql = "SELECT * FROM tbl_sample ORDER BY id DESC";$result = mysqli_query($connect, $sql); if(mysqli_num_rows($result) > 0){$output .= '<table class="table" bordered="1"›IdFirst NameLast Name';while($row = mysqli_fetch_array($result)){$output .= ''.$row["id"]. ''.$row["first_name"]. ''.$row["last_name"]. ' ';} $output .= ''; header("Content-Type: application/xls"); header("Content-Disposition: attachment; filename=download.xls"); echo $output; }}What I have tried:This is coding that i change data.php Userexcel.php<?php$connect = mysqli_connect("localhost", "root", "", "flight");$output = ''; if(isset($_POST["export_excel"])){$sql = "SELECT * FROM customer ORDER BY id DESC";$result = mysqli_query($connect, $sql); if(mysqli_num_rows($result) > 10){$output .= '<table class="table" bordered="1"›';while($row = mysqli_fetch_array($result)){$output .= ' ';} $output .= 'IdCustomer NameCustomer IC:Customer State:Customer EmailCustomer Address'.$row["id"]. ''.$row["CustomerID"]. ''.$row["CustomerName"]. ''.$row["CustomerNric"]. ''.$row["State"]. ''.$row["Email"]. ''.$row["Address"]. ''; header("Content-Type: application/xls"); header("Content-Disposition: attachment; filename=download.xls"); echo $output; }}推荐答案 connect = mysqli_connect(localhost,root,,test_db);connect = mysqli_connect("localhost", "root", "", "test_db"); output =''; if(isset(output = ''; if(isset( _POST [export_excel]) ) {_POST["export_excel"])){ 这篇关于将SQL数据转换为excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-23 21:04