Hello all
I have created a page for my site that will allow me to export certain data to cvs file. Now this works and i can down load it off my server and all is fine there.
Here comes the question.
I have an array that i fill from my database and that works. But when i do pull that data it repeats the same information twice.
for example
1,1,firstname,firstname,lastname,lastname
and so on.
here is my code
// Create an instance of DbConnector and Validator
$connector = new DbConnector();
$result = $connector->query('SELECT ID,user,thegroup,firstname,surname,enabled,created,logged_in,log_time,last_log FROM cmsusers ORDER BY ID');
while ($row = $connector->fetchArray($result)){
//create array of data from table
$usertrack[] = $row;
}
function makeCSV($data, $sep = ','){
if(!is_array($data)){
return 'no data';
}
$ret = '';
foreach($data as $record){
if(is_array($record)){
$ret .= join($sep, $record) . "
";
}
}
return $ret;
}
echo makeCSV($usertrack);
Now the second part is this. I’ve seen it done and found a page on google that told me how to do this but i lost it and for the life of me can’t find it again.
how can i get the title of each element from that array?
so if something is added in under firstname then the title of that part of the array is firstname.
If that doesn’t make sense then please don’t hesitate to ask.