0

here is my code:

    function download1() {
    $this->load->dbutil();
    $this->load->helper('file');
    $this->load->helper('download');
    $delimiter = ",";
    $newline = "\r\n";
    $filename = "filename_you_wish.csv";
    $query = $this->db->query("SELECT TABLE_NAME 
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA='sample_db'");
    $res = $query->result_array();
    foreach ($res as $row):
        $filename = $row['TABLE_NAME'] . '.csv';
        $q = "select * from " . $row['TABLE_NAME'];
        $result = $this->db->query($q);
        $data = $this->dbutil->csv_from_result($result,$delimiter,$newline);
        force_download($filename, $data);
    endforeach;
    }

It just downloads th first table and no more. i want all the tables to download.

  • Consider how HTTP works. For a given request, there is *one* response. What should that response be? If you want to package multiple files into a single response, it sounds like you're looking for a ZIP library of some sort. – David Oct 20 '16 at 12:34
  • Return an HTML page with iframes which will trigger each download. Check http://stackoverflow.com/questions/3749231/download-file-using-javascript-jquery – apokryfos Oct 20 '16 at 12:41
  • ok. thanks. Let me see. – Debraj Chatterjee Oct 20 '16 at 13:21

0 Answers0