PHP的MySQL导出应创build下拉菜单

我试图从我的MySQL数据库的一部分进行.xls导出。 我想出了以下溶剂:

//从数据库获取数据并将其写入表中

$siteNumber = 999; $results = Db::getInstance()->queryResults('SELECT * FROM `configurations`'); ?> <table border="1"> <tr> <th>Configuration id</th> <th>Configuration category</th> <th>Configuration name</th> </tr> <?php foreach($results as $result => $key) { $str = '<tr>'; $str .= '<td>'.$key->configuration_id .'</td>'; $str .= '<td>'.$key->configuration_category .'</td>'; $str .= '<td>'.$key->configuration_name .'</td>'; $str .= '</tr>'; echo $str; } ?> </tr> </table> 

//我使用头创build一个excelfile

 <?php // Add data table include 'exceldata.php'; // The function header by sending raw excel header("Content-type: application/vnd-ms-excel"); // Defines the name of the export file "codelution-export.xls" header("Content-Disposition: attachment; filename=test.xls"); ?> 

这一切工作正常,并输出一个不错的表格。 我试图实现的是所有结果被导出按照configuration类别作为下拉列表。

有没有办法做到这一点?

提前致谢!

我不知道我明白 但是,如果你想显示包括下拉列表的exelfile,你可以只使用无序列表的HTML

我想这个: https : //github.com/PHPOffice/PHPExcel是你需要的。

PHPExcel将允许您创build漂亮的电子表格并将其导出为Excel格式。

您也可以使用此库创buildExcel DropDown。 详细信息请参阅此页面: 阅读下拉列表中的选项列表 – Phpexcel