tags:

views:

369

answers:

5
+1  A: 

php isn't really my thing, but it seems like you need to clear the response stream before writing out your content. Perhaps something else is writing html out to the stream, before reaching this function? Like a template or master page or something of that nature?

The HTML content looks like a typical header/nav bar. if there something else that's automatically including that content that you need to disable for this route?

Troy Howard
A: 

You've got a control flow problem somewhere - it seems the html head part and navigation is included by default in any page, including in the one that generates the CSV. One solution would be to check for a CSV request and if that's the case, don't include the html code, another one would be to use output buffering and then discard all the previous output right before outputting the CSV data.

Nouveau
I have a function just to print out the navigation on the index page. The index page is basically a switch statement executing the appropriate function based on what link you click.
Brad
A: 

I suggest initializing the csv_output variable to the empty string at the start of your method. All of your operations in the method are concatenations, so you are likely bringing along some old data.

KeithL
Set it to $csv_output = '';It did not work, thank you though.
Brad
+3  A: 

My guess is that you've got some sort of template that generates the same HTML header and footer regardless of the page that is requested. Sometime before the exportCSV function is called, the header is generated.

You don't show the bottom of the output, but I'll bet the footer is there too, since I suspect the flow control will continue on to that code after the function exits.

Steve Moyer
It is one page with the navigation included. How would I solve this? Should I have the export function open into a new blank page?
Brad
In the code that produces the header and footer, bypass the code if you're producing a CSV file. In order to be any further help, you'll need to include more code. By the way, kudos on your content header set-up ... that's the part most people mess up!
Steve Moyer
A: 

Please consider that you are showing potentially sensitive data to the entire world. You've got a dozen people who now have their email and street addresses published.

Andy Lester
Wow ... I looked right at the image and never even considered that ... it's amazing how blind you can be when focused on something else.
Steve Moyer
Even with blurred text, you can decifer it. Each letter produces a unique blur pattern, and since there are only a limited number of letter characters, it's easy to figure out the blur pattern of each and get the original text. Although that's probably a lot of work to get some email addresses.
Kibbee