简体   繁体   English

仅导出PHP中的选定列

[英]Export only selected columns in php

Previously it was hardcoded, but now the requirement is that I want to download only the selected columns. 以前是硬编码的,但现在的要求是我只想下载选定的列。

In View: 在视图中:

foreach ($allColumnsDBArray as $colHeading) { ?>
    <input type="checkbox" class='form' name="selectedcols[]" value="<?php echo "$colHeading"; ?>" />
    <?php echo $colHeading; echo "<br>";
}

In Controller: 在控制器中:

public function actionExport_csv() {
    $model = new Companies();
    $session = Yii::$app->session;             
    if(isset($_POST['download'])){ if(!empty($_POST['selectedcols'])) {
        foreach($_POST['selectedcols'] as $check) {
            echo $check;//what will be the code here to download column in selectedcols
         }
    } 
}

我使用导出菜单小部件导出选定的列

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM