I have this code below and what it does is it generates a CSV from data from the database and it works fine. My only issue is that I want to add another field to the CSV (in the middle and not in the end if possible) is this possible? the field would take the DOB from the data and give that person a title based on age (born after 1994 they are 'Junior' born after they are 'Senior') and so on, there are like 4 or 5 different titles an age can be. I hope this makes sense.
function csv_all_members(){
$this->load->dbutil();
$this->db->select("first_name as 'First Name', last_name as 'Last Name', phone as 'Phone', os.group as 'Group', gender as 'Gender', birth_date as 'DOB', email as 'Email', street_address as 'Address', city as 'City', province as 'Province', postal_code as 'Postal Code', country 'Country', payment_amount as 'Payment Amount', DATE_FORMAT(payment_date, '%d/%m/%Y') as 'Payment Date', an.notes as 'Notes'", false);
$this->db->from('offline_shoppers os');
$this->db->join('athlete_notes an', 'os.id = an.id', 'inner');
$this->db->group_by(array("first_name", "last_name"));
$this->db->order_by("last_name asc, first_name asc");
$query = $this->db->get();
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=members_list.csv");
header("Pragma: no-cache");
header("Expires: 0");
echo $this->dbutil->csv_from_result($query);
}