jacko1607 Posted March 28, 2012 Share Posted March 28, 2012 I have researched on this and have some solutions – but would like to get some advice on my particular case. The website I am working on is Joomla based. I have a user form which when submitted runs a query on the database and returns values. From this query I require the ability to export the results as either a CSV or PDF (PDF preferred). If possible, I would prefer to avoid any Javascript method to do this as I am not familiar with it. Obviously the simplest and quickest method is preferred but any advice on how to do this? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/259847-export-sql-query-to-pdf-or-csv-with-php/ Share on other sites More sharing options...
The Letter E Posted March 28, 2012 Share Posted March 28, 2012 http://www.fpdf.org/ I have used FPDF before and it worked well. I think that, or any other 3rd party resource you can find, is best for PDF creation. No JS required. If you want to create a .csv file that's a simple as: $csv_array = array( array('column1', 'column2', 'column3'), //heading row array('some data here', 'some data there', 'then some more data'), //data row 1 array('some data here', 'some data there', 'then some more data') //data row 2 //etc... ); $handle = fopen('path/to/file/filename.csv', 'w'); foreach($csv_array as $row){ fputcsv($handle, $row); } fclose($handle); Quote Link to comment https://forums.phpfreaks.com/topic/259847-export-sql-query-to-pdf-or-csv-with-php/#findComment-1331810 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.