【发布时间】:2020-05-27 15:18:55
【问题描述】:
我正在尝试将我的数据库获取的数据导入 Excel 文件,以将其下载到 execl 或 csv 中,但我在导出时遇到了问题。不是数据被提取到 csv 。这是我的代码:
<div><a href="javascript:void(0)" id="export-to-csv">Export to csv</a></div>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" id="export-form">
<input type="hidden" value='' id='hidden-type' name='ExportType'/>
</form>
<table id="data-table" class="table table-bordered table-striped">
<thead>
<tr style="background-color: cornflowerblue;">
<th>Invoice No.</th>
<th>Invoice Date</th>
<th>Student Name</th>
<th>Total Amount</th>
</tr>
</thead>
<?php
if($total_rows > 0)
{
foreach($all_result as $row)
{
echo '
<tr>
<td>'.$row["order_no"].'</td>
<td>'.$row["order_date"].'</td>
<td>'.$row["order_receiver_name"].'</td>
<td>'.$row["order_total_after_tax"].'</td>
</tr>
';
}
}
?>
</table>
<?php
}
?>
【问题讨论】:
-
什么是 $total_rows 和 $all_result?