FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Send .csv file to browser
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Send .csv file to browser [message #170047 is a reply to message #170046] Thu, 07 October 2010 12:08 Go to previous messageGo to previous message
Derek Turner is currently offline  Derek Turner
Messages: 48
Registered: October 2010
Karma:
Member
On Thu, 07 Oct 2010 10:25:50 +0000, Derek Turner wrote:

> <snip very useful material>
>
> Many thanks, Jerry, I'll give it a go and report back.

<?php
include("/home/cantabi1/admin_connect.php");
$sql = "SELECT `givenName`, `familyName`, `email`, `mobile`, `landLine`
FROM `member` WHERE `active` = 1";
$result = mysql_query($sql, $conn) or die (mysql_error());
if ($result) {
$outfile = fopen('php://output', 'w');
header('Content-Type: text/csv');
header('Content-disposition: attachment; filename=data.csv');
while ($row = mysql_fetch_array($result)) {
fputcsv($outfile, $row);
}
fclose($outfile);
}
?>

Produces a csv file just fine BUT each variable is doubled up i.e.
Derek,Derek,Turner,Turner, etc. can anyone see why?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: file access permission?
Next Topic: Process queue without cron jobs
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 11:38:50 GMT 2024

Total time taken to generate the page: 0.04379 seconds