I'm using php. I'd like to know how can I dynamically export data to excel file (.xls). in the query below in entered the fields in the clause Select which i want to see in the excel file. 

```
$query = "SELECT f.attendee_id as id1, f.answer as Prenom, l.answer as Nom, c1.answer as choix
         FROM wp_events_answer f
         JOIN wp_events_answer l ON f.attendee_id = l.attendee_id
         JOIN wp_events_answer c1 ON f.attendee_id = c1.attendee_id
         WHERE (f.question_id = 1) AND (l.question_id = 2) AND (c1.question_id = 28);";

```

And i also entered the labels of this fields: 

```
$tbl= " <table border='1'>
<tr height='50px'><td WIDTH='50px' align='center'>ID</td><td WIDTH='50px'   align='center'>Prenom</td><td WIDTH='50px'align='center'>Nom</td><td WIDTH='50px' align='center'>Choix 1</td><td WIDTH='50px' align='center'>Choix 2</td></tr>";.;

```

But i'd like that all this became dynamic because the user can create and modify the forms. So if the user add or modify a field the export will only works if this field is also modified in the code (Select clause).

Can you explain me how can I do this?

Thanks