Welcome Guest, Not a member yet? Register   Sign In
Exporting current query results to CSV


Is there a way I can export current query results to CSV? I have look through the forums and in most examples, you either have to export the entire table. In my current scenario, I have filtered my data to display a particular set of results and its the filtered output that I want to export as CSV.

Anyone have an idea on achieving this?





$query = $this->db->query("SELECT * FROM mytable");

echo $this->dbutil->csv_from_result($query);


Hi NeoArc,

That just allows you to export the entire contents of a table to a csv. However the data is not filtered! Thanks again however.

You should learn some MySQL Wink

$query = $this->db->query(“SELECT id, name, date, telephone FROM users
WHERE creation_date < '2010-11-10' AND status=1 ORDER BY id DESC LIMIT 20”);

Theme © iAndrew 2016 - Forum software by © MyBB