![]() |
Doing some logic for exporting CSV - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Doing some logic for exporting CSV (/showthread.php?tid=59018) |
Doing some logic for exporting CSV - El Forum - 08-15-2013 [eluser]Hantar[/eluser] I have a table in my DB with following headers: user, category, title, marks And values in it are like this Code: User1 - Food - Pizza - 19 This is also the way it printed in my CSV file, But what I'm trying to achieve in my CSV file is this format Code: A(user) B(=category) C D E This basically what I'm trying to achieve - Sorting the user then sorting the category's that the user has and then at every category the user has print the titles and the scores. But How can I sort and do logic for putting in a CSV? I have the following code Model: Code: function CSV(){ Controller: Code: function exporting(){ Doing some logic for exporting CSV - El Forum - 08-15-2013 [eluser]CroNiX[/eluser] Can't all of the sorting be done in your mysql query? Code: $query = $this->db As far as how to output it in your csv, you'll have to do that manually instead of using the csv helper. Just iterate over $query->result_array() and use logic to do your formatting. |